From 5e506bfab0b6d507b323519b3830bb0485d43560 Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 24 Sep 2021 16:36:02 +0200 Subject: [PATCH 01/84] Trigger F1 UE context setup request from CU after reception of NR UE capabilities -Include UE_Capability_RAT_container_list in UE context setup request so that it gets processed at the DU -Next steps: DU should store and process the UE capabilities and generate updates in master cell group config to be included in UE context setup response. Then upon reception of UE context setup response, the first RRC Reconfiguration can be triggered at the CU with the updates on master cell group config. --- openair2/COMMON/f1ap_messages_types.h | 11 ++- openair2/F1AP/f1ap_cu_ue_context_management.c | 40 +++++++---- openair2/F1AP/f1ap_du_ue_context_management.c | 5 +- openair2/RRC/NR/rrc_gNB.c | 71 +++++++++++++++++-- 4 files changed, 103 insertions(+), 24 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 1aba05e82d..7116dd09c1 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -343,6 +343,15 @@ typedef struct f1ap_rb_failed_to_be_setup_s { long rb_id; } f1ap_rb_failed_to_be_setup_t; +typedef struct cu_to_du_rrc_information_s { + uint8_t * cG_ConfigInfo; + uint8_t cG_ConfigInfo_length; + uint8_t * uE_CapabilityRAT_ContainerList; + uint8_t uE_CapabilityRAT_ContainerList_length; + uint8_t * measConfig; + uint8_t measConfig_length; +}cu_to_du_rrc_information_t; + typedef struct f1ap_ue_context_setup_s { uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti uint32_t gNB_DU_ue_id; @@ -355,7 +364,7 @@ typedef struct f1ap_ue_context_setup_s { uint8_t servCellIndex; uint8_t *cellULConfigured; uint32_t servCellId; - uint8_t *cu_to_du_rrc_information; + cu_to_du_rrc_information_t *cu_to_du_rrc_information; uint8_t cu_to_du_rrc_information_length; uint8_t *du_to_cu_rrc_information; uint8_t du_to_cu_rrc_information_length; diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 5030e84e35..6910c9d71b 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -132,21 +132,31 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ie6->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; ie6->criticality = F1AP_Criticality_reject; ie6->value.present = F1AP_UEContextSetupRequestIEs__value_PR_CUtoDURRCInformation; - /* optional */ - /* 6.1 cG_ConfigInfo */ - if (0) { - const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; - asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.cG_ConfigInfo, F1AP_CG_ConfigInfo_t, cG_ConfigInfo); - OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + + if (f1ap_ue_context_setup_req->cu_to_du_rrc_information!=NULL) { + /* optional */ + /* 6.1 cG_ConfigInfo */ + if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->cG_ConfigInfo!=NULL){ + const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.cG_ConfigInfo, F1AP_CG_ConfigInfo_t, cG_ConfigInfo); + OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen(cG_ConfigInfoStr)) ; + } /* optional */ /* 6.2 uE_CapabilityRAT_ContainerList */ - asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, F1AP_UE_CapabilityRAT_ContainerList_t, uE_CapabilityRAT_ContainerList ); - OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, F1AP_UE_CapabilityRAT_ContainerList_t, uE_CapabilityRAT_ContainerList ); + OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, (const char *)f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, + f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length) ; + } /* optional */ /* 6.3 measConfig */ - asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.measConfig, F1AP_MeasConfig_t, measConfig); - OCTET_STRING_fromBuf(measConfig, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->measConfig!=NULL){ + const char measConfigStr[]="asdsa1d32sa1d31asd31as"; + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.measConfig, F1AP_MeasConfig_t, measConfig); + OCTET_STRING_fromBuf(measConfig, measConfigStr, strlen(measConfigStr)) ; + } } + /* mandatory */ /* c7. Candidate_SpCell_List */ @@ -238,6 +248,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* mandatory */ /* c11. SRBs_ToBeSetup_List */ + if(f1ap_ue_context_setup_req->srbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie11); ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List; ie11->criticality = F1AP_Criticality_reject; // ? @@ -260,9 +271,11 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, F1AP_DuplicationIndication_t, F1AP_DuplicationIndication_true); // enum //} } + } /* mandatory */ /* c12. DRBs_ToBeSetup_List */ + if(f1ap_ue_context_setup_req->drbs_to_be_setup_length){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie12); ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List; ie12->criticality = F1AP_Criticality_reject; @@ -511,16 +524,14 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ for (int j = 0; j < f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { - /* Here the callback function used as input is not the right one. Need to create a new one probably for F1-U, not sure - * if the kind of input parameters to the callback function are convenient though for gtp-u over F1-U.*/ - //Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU + /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ transport_layer_addr_t addr; int sz=sizeof(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); memcpy(addr.buffer,&f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); addr.length = sz*8; f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= - newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, f1ap_ue_context_setup_req->rnti, f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, @@ -567,6 +578,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, *tmp = F1AP_DuplicationActivation_active; // enum } } + } /* OPTIONAL */ /* InactivityMonitoringRequest */ diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 70556e78c7..818c18c173 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -134,7 +134,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* DRB */ F1AP_UEContextSetupRequestIEs_t *ieDrb; F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container, - F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true); + F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, false); if(ieDrb!=NULL) { f1ap_ue_context_setup_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetup_List.list.count; @@ -187,7 +187,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* SRB */ F1AP_UEContextSetupRequestIEs_t *ieSrb; F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieSrb, container, - F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, true); + F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, false); if(ieSrb != NULL) { f1ap_ue_context_setup_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetup_List.list.count; @@ -580,6 +580,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup getCxt(false, instance)->default_sctp_stream_id); return 0; } + int DU_send_UE_CONTEXT_SETUP_FAILURE(instance_t instance) { AssertFatal(1==0,"Not implemented yet\n"); } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e240c9d269..bd6ce4c7de 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1347,7 +1347,6 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); /* Refresh SRBs/DRBs */ - if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, @@ -1367,7 +1366,7 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } - else if(SRB_configList!=NULL || DRB_configList!=NULL){ + /*else if(SRB_configList!=NULL || DRB_configList!=NULL){ MessageDef *message_p; message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ); f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); @@ -1409,7 +1408,7 @@ rrc_gNB_process_RRCReconfigurationComplete( LOG_I(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n"); } itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); - } + }*/ #endif /* Set the SRB active in UE context */ @@ -2690,11 +2689,69 @@ rrc_gNB_decode_dcch( ul_dcch_msg); } - if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { - rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p); - } else { - rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); + if(!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)){ + if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { + rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p); + } else { + rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); + } } + else{ + /*Generate a UE context setup request message towards the DU to provide the UE + *capability info and get the updates on master cell group config from the DU*/ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ); + f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); + //UE_IDs will be extracted from F1AP layer + req->gNB_CU_ue_id = 0; + req->gNB_DU_ue_id = 0; + req->rnti = ue_context_p->ue_context.rnti; + req->mcc = RC.nrrrc[ctxt_pP->module_id]->configuration.mcc[0]; + req->mnc = RC.nrrrc[ctxt_pP->module_id]->configuration.mnc[0]; + req->mnc_digit_length = RC.nrrrc[ctxt_pP->module_id]->configuration.mnc_digit_length[0]; + req->nr_cellid = RC.nrrrc[ctxt_pP->module_id]->nr_cellid; + + if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { + /*Instruction towards the DU for SRB2 configuration*/ + req->srbs_to_be_setup = malloc(1*sizeof(f1ap_srb_to_be_setup_t)); + req->srbs_to_be_setup_length = 1; + f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; + SRBs[0].srb_id = 2; + SRBs[0].lcid = 2; + + /*Instruction towards the DU for DRB configuration and tunnel creation*/ + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; + memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); + req->drbs_to_be_setup = malloc(1*sizeof(f1ap_drb_to_be_setup_t)); + req->drbs_to_be_setup_length = 1; + f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; + LOG_I(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length); + DRBs[0].drb_id = 1; + DRBs[0].rlc_mode = RLC_MODE_AM; + DRBs[0].up_ul_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt_pP->module_id]->eth_params_s.my_addr); + DRBs[0].up_ul_tnl[0].port=RC.nrrrc[ctxt_pP->module_id]->eth_params_s.my_portd; + DRBs[0].up_ul_tnl_length = 1; + DRBs[0].up_dl_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt_pP->module_id]->eth_params_s.remote_addr); + DRBs[0].up_dl_tnl[0].port=RC.nrrrc[ctxt_pP->module_id]->eth_params_s.remote_portd; + DRBs[0].up_dl_tnl_length = 1; + } + if( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.present == + NR_UECapabilityInformation__criticalExtensions_PR_ueCapabilityInformation ) { + struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList = + ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList; + + req->cu_to_du_rrc_information = calloc(1,sizeof(cu_to_du_rrc_information_t)); + req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = calloc(1,1024); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_CapabilityRAT_ContainerList, + NULL, + (void *)ue_CapabilityRAT_ContainerList, + req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, + 1024); + req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = (enc_rval.encoded+7)>>3; + } + itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); + } + break; From 55476b175f94aa23091798b5edcf6caf063595b4 Mon Sep 17 00:00:00 2001 From: matzakos Date: Mon, 27 Sep 2021 18:02:13 +0200 Subject: [PATCH 02/84] Handle UE capabilities info at the DU received through UE context setup request -Trigger UE context setup response at the DU and RRC Reconfiguration at the CU upon reception of UE context setup response. -Pending: The DU should generate some updates on the master cell groupconfig based also on the received UE capabilities and add them in the UE context setup response message so that they can be included in the RRC Reconfiguration message sent from the CU. For the moment the corresponding function is empty. -Next steps: trigger UE context modification procedures --- openair2/F1AP/f1ap_cu_ue_context_management.c | 4 +- openair2/F1AP/f1ap_du_ue_context_management.c | 16 ++ openair2/RRC/NR/MESSAGES/asn1_msg.c | 169 ++++++++++-------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 4 +- openair2/RRC/NR/nr_rrc_proto.h | 3 +- openair2/RRC/NR/rrc_gNB.c | 133 +++++++++++++- openair2/RRC/NR/rrc_gNB_NGAP.c | 2 +- 7 files changed, 238 insertions(+), 93 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 6910c9d71b..740d3a75b4 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -696,7 +696,7 @@ int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, // DRBs_Setup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DRBs_Setup_List, true); + F1AP_ProtocolIE_ID_id_DRBs_Setup_List, false); if(ie!=NULL){ f1ap_ue_context_setup_resp->drbs_to_be_setup_length = ie->value.choice.DRBs_Setup_List.list.count; f1ap_ue_context_setup_resp->drbs_to_be_setup = calloc(f1ap_ue_context_setup_resp->drbs_to_be_setup_length, @@ -762,7 +762,7 @@ int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, // SRBs_Setup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_SRBs_Setup_List, true); + F1AP_ProtocolIE_ID_id_SRBs_Setup_List, false); if(ie!=NULL){ f1ap_ue_context_setup_resp->srbs_to_be_setup_length = ie->value.choice.SRBs_Setup_List.list.count; f1ap_ue_context_setup_resp->srbs_to_be_setup = calloc(f1ap_ue_context_setup_resp->srbs_to_be_setup_length, diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 818c18c173..e2f804c35b 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -131,6 +131,18 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, f1ap_ue_context_setup_req->cellULConfigured = NULL; } + F1AP_UEContextSetupRequestIEs_t *ieCuRrcInfo; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieCuRrcInfo, container, + F1AP_ProtocolIE_ID_id_CUtoDURRCInformation, false); + if(ieCuRrcInfo!=NULL){ + f1ap_ue_context_setup_req->cu_to_du_rrc_information = (cu_to_du_rrc_information_t *)calloc(1,sizeof(cu_to_du_rrc_information_t)); + if(ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList!=NULL){ + f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = (uint8_t *)calloc(1,ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size); + memcpy(f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->buf, ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size); + f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size; + } + } + /* DRB */ F1AP_UEContextSetupRequestIEs_t *ieDrb; F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container, @@ -334,6 +346,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* mandatory */ /* c7. DRBs_Setup_List */ + if(req->drbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie7); ie7->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List; ie7->criticality = F1AP_Criticality_ignore; @@ -374,6 +387,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup INT32_TO_OCTET_STRING(req->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); } // for j } // for i + } /* mandatory */ /* c8. SRBs_FailedToBeSetup_List */ @@ -523,6 +537,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* mandatory */ /* c11. SRBs_Setup_List */ + if(req->srbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie11); ie11->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_List; ie11->criticality = F1AP_Criticality_ignore; @@ -540,6 +555,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* sRBID */ srbs_setup_item->sRBID = req->srbs_to_be_setup[i].srb_id; } + } /* Optional */ /* c12. InactivityMonitoringResponse */ diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f1930f65a4..143eac680d 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1096,7 +1096,7 @@ void fill_initial_SpCellConfig(rnti_t rnti, SpCellConfig->spCellConfigDedicated->tag_Id=0; } -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) { +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, uint8_t SRB_config_present, uint8_t DRB_config_present) { cellGroupConfig->cellGroupId = 0; cellGroupConfig->rlc_BearerToReleaseList = NULL; @@ -1104,86 +1104,97 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr // RLC Bearer Config // TS38.331 9.2.1 Default SRB configurations - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; - long *logicalChannelGroup = NULL; - rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 2; - rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); - rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 2; - rlc_BearerConfig->reestablishRLC = NULL; - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 3; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + if(SRB_config_present){ + NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; + NR_RLC_Config_t *rlc_Config = NULL; + NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; + long *logicalChannelGroup = NULL; + rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig->logicalChannelIdentity = 2; + rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); + rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; + rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 2; + rlc_BearerConfig->reestablishRLC = NULL; + rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config->present = NR_RLC_Config_PR_am; + rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); + rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; + rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; + rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; + rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; + rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; + rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; + rlc_BearerConfig->rlc_Config = rlc_Config; + logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); + logicalChannelConfig->ul_SpecificParameters->priority = 3; + logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5; + logicalChannelGroup = CALLOC(1, sizeof(long)); + *logicalChannelGroup = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; + logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + } // DRB Configuration - NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; - NR_RLC_Config_t *rlc_Config_drb = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; - long *logicalChannelGroup_drb = NULL; - rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig_drb->logicalChannelIdentity = 4; - rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); - rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; - rlc_BearerConfig_drb->reestablishRLC = NULL; - rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config_drb->present = NR_RLC_Config_PR_am; - rlc_Config_drb->choice.am = calloc(1, sizeof(*rlc_Config_drb->choice.am)); - rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config_drb->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms80; - rlc_Config_drb->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms10; - rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config_drb->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; - rlc_Config_drb->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; - rlc_Config_drb->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; - rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t4; - rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; - logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); - logicalChannelConfig_drb->ul_SpecificParameters->priority = 13; - logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; - logicalChannelGroup_drb = CALLOC(1, sizeof(long)); - *logicalChannelGroup_drb = 1; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; - logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + if(DRB_config_present){ + NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; + NR_RLC_Config_t *rlc_Config_drb = NULL; + NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; + long *logicalChannelGroup_drb = NULL; + rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig_drb->logicalChannelIdentity = 4; + rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); + rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; + rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; + rlc_BearerConfig_drb->reestablishRLC = NULL; + rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config_drb->present = NR_RLC_Config_PR_am; + rlc_Config_drb->choice.am = calloc(1, sizeof(*rlc_Config_drb->choice.am)); + rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; + rlc_Config_drb->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms80; + rlc_Config_drb->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms10; + rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; + rlc_Config_drb->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; + rlc_Config_drb->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; + rlc_Config_drb->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; + rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t4; + rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; + logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); + logicalChannelConfig_drb->ul_SpecificParameters->priority = 13; + logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; + logicalChannelGroup_drb = CALLOC(1, sizeof(long)); + *logicalChannelGroup_drb = 1; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; + logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + } +} + +void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup){ + /*Function to be filled with the updates on the cellGroupConfig at the UE context, + * upon reception of the NR UE capabilities at the gNB. This cellGroupConfig information + * should be communicated to the UE through the first (default) RRC Reconfiguration message*/ + LOG_I(NR_RRC, "Implementation pending \n"); } void fill_initial_cellGroupConfig(rnti_t rnti, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 419352255a..696a5a9839 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -97,7 +97,9 @@ void fill_initial_cellGroupConfig(rnti_t rnti, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc); -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup); +void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup); + +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, uint8_t SRB_config_present, uint8_t DRB_config_present); uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t *const buffer, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 9465b9b4b0..2ac8d14a23 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -204,4 +204,5 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( void rrc_gNB_generate_dedicatedRRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP); + rrc_gNB_ue_context_t *ue_context_pP, + NR_CellGroupConfig_t *cell_groupConfig_from_DU); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index bd6ce4c7de..0208cc4a57 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -746,7 +746,8 @@ rrc_gNB_process_RRCSetupComplete( void rrc_gNB_generate_defaultRRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP + rrc_gNB_ue_context_t *ue_context_pP, + NR_CellGroupConfig_t *cellGroupConfig ) //----------------------------------------------------------------------------- { @@ -871,7 +872,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( NULL, dedicatedNAS_MessageList, NULL, - NULL); + cellGroupConfig); free(ue_context_pP->ue_context.nas_pdu.buffer); @@ -960,7 +961,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( void rrc_gNB_generate_dedicatedRRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP + rrc_gNB_ue_context_t *ue_context_pP, + NR_CellGroupConfig_t *cell_groupConfig_from_DU ) //----------------------------------------------------------------------------- { @@ -980,7 +982,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( NR_QFI_t qfi = 0; int pdu_sessions_done = 0; int i; - NR_CellGroupConfig_t *cellGroupConfig; + NR_CellGroupConfig_t *cellGroupConfig = NULL; uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); @@ -1117,8 +1119,13 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( } memset(buffer, 0, RRC_BUF_SIZE); - cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup); + if(cell_groupConfig_from_DU == NULL){ + cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup,1,1); + } + else{ + cellGroupConfig = cell_groupConfig_from_DU; + } size = do_RRCReconfiguration(ctxt_pP, buffer, xid, *SRB_configList2, @@ -2691,9 +2698,9 @@ rrc_gNB_decode_dcch( if(!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)){ if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { - rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p); + rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p, NULL); } else { - rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); + rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p, NULL); } } else{ @@ -2747,6 +2754,8 @@ rrc_gNB_decode_dcch( (void *)ue_CapabilityRAT_ContainerList, req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, 1024); + AssertFatal (enc_rval.encoded > 0, "ASN1 ue_CapabilityRAT_ContainerList encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = (enc_rval.encoded+7)>>3; } itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); @@ -3221,9 +3230,99 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha uint32_t incoming_teid = 0; + if(req->cu_to_du_rrc_information!=NULL){ + if(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ + LOG_I(NR_RRC, "Length of ue_CapabilityRAT_ContainerList is: %d \n", (int) req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); + struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList; + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_UE_CapabilityRAT_ContainerList, + (void **)&ue_CapabilityRAT_ContainerList, + (uint8_t *)req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, + (int) req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + AssertFatal(1==0,"UE Capability RAT ContainerList decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_UE_CapabilityRAT_ContainerList, ue_CapabilityRAT_ContainerList, 1 ); + return; + } + /*To fill ue_context.UE_Capability_MRDC, ue_context.UE_Capability_nr ...*/ + int NR_index = -1; + for(int i = 0;i < ue_CapabilityRAT_ContainerList->list.count; i++){ + if(ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == + NR_RAT_Type_nr){ + LOG_I(NR_RRC, "DU received NR_RAT_Type_nr UE capabilities Info through the UE Context Setup Request from the CU \n"); + if(ue_context_p->ue_context.UE_Capability_nr){ + ASN_STRUCT_FREE(asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); + ue_context_p->ue_context.UE_Capability_nr = 0; + } + + dec_rval = uper_decode(NULL, + &asn_DEF_NR_UE_NR_Capability, + (void**)&ue_context_p->ue_context.UE_Capability_nr, + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.buf, + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size, + 0,0); + if(LOG_DEBUGFLAG(DEBUG_ASN1)){ + xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); + } + + if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)){ + LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Failed to decode nr UE capabilities (%zu bytes)\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(&ctxt),dec_rval.consumed); + ASN_STRUCT_FREE(asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); + ue_context_p->ue_context.UE_Capability_nr = 0; + } + + ue_context_p->ue_context.UE_Capability_size = + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size; + if(NR_index != -1){ + LOG_E(NR_RRC,"fatal: more than 1 eutra capability\n"); + exit(1); + } + NR_index = i; + } + + if(ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == + NR_RAT_Type_eutra_nr){ + LOG_I(NR_RRC, "DU received NR_RAT_Type_eutra_nr UE capabilities Info through the UE Context Setup Request from the CU \n"); + if(ue_context_p->ue_context.UE_Capability_MRDC){ + ASN_STRUCT_FREE(asn_DEF_NR_UE_MRDC_Capability,ue_context_p->ue_context.UE_Capability_MRDC); + ue_context_p->ue_context.UE_Capability_MRDC = 0; + } + dec_rval = uper_decode(NULL, + &asn_DEF_NR_UE_MRDC_Capability, + (void**)&ue_context_p->ue_context.UE_Capability_MRDC, + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.buf, + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size, + 0,0); + if(LOG_DEBUGFLAG(DEBUG_ASN1)){ + xer_fprint(stdout,&asn_DEF_NR_UE_MRDC_Capability,ue_context_p->ue_context.UE_Capability_MRDC); + } + + if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)){ + LOG_E(NR_RRC,PROTOCOL_NR_RRC_CTXT_FMT" Failed to decode nr UE capabilities (%zu bytes)\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(&ctxt),dec_rval.consumed); + ASN_STRUCT_FREE(asn_DEF_NR_UE_MRDC_Capability,ue_context_p->ue_context.UE_Capability_MRDC); + ue_context_p->ue_context.UE_Capability_MRDC = 0; + } + ue_context_p->ue_context.UE_MRDC_Capability_size = + ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size; + } + + if(ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == + NR_RAT_Type_eutra){ + //TODO + } + } + } + } + + + NR_CellGroupConfig_t *cellGroupConfig; cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup); + update_cellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup); /* Configure SRB2 */ NR_SRB_ToAddMod_t *SRB2_config = NULL; @@ -3272,6 +3371,12 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha } } + if(req->srbs_to_be_setup_length>0 || req->drbs_to_be_setup_length>0){ + fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, + req->srbs_to_be_setup_length>0 ? 1:0, + req->drbs_to_be_setup_length>0 ? 1:0); + } + apply_macrlc_config(rrc, ue_context_p, &ctxt); /* Fill the UE context setup response ITTI message to send to F1AP */ resp->gNB_CU_ue_id = req->gNB_CU_ue_id; @@ -3307,6 +3412,10 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha else{ LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context setup request at the DU\n"); } + /* fixme: + * Here we should be probably be encoding to UE ctxt setup response the updates on cellgroupconfig (i.e., cellGroupConfig) + * instead of the whole masterCellGroup configuration stored at the UE context (i.e., ue_context_p->ue_context.masterCellGroup). + */ resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, @@ -3357,6 +3466,12 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch } xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); + if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { + rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, cellGroupConfig); + } else { + rrc_gNB_generate_defaultRRCReconfiguration(&ctxt, ue_context_p, NULL); + } + free(cellGroupConfig->rlc_BearerToAddModList); free(cellGroupConfig); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index e8e5055cfe..7b2fb5ac10 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1111,7 +1111,7 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( // TEST // ue_context_p->ue_context.pdusession[0].status = PDU_SESSION_STATUS_DONE; // rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(&ctxt, ue_context_p, 0); - rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p); + rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, NULL); return(0); } } From 36b8bb1b5bfbfd22d763dd0f94d811c79bfe69b9 Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 5 Oct 2021 13:43:19 +0200 Subject: [PATCH 03/84] Trigger UE context modification request at the CU upon reception of PDU Session Resource setup request from the AMF -F1 message successfully encoded at the CU (including SRB2, DRB and F1-U tunnel configuration) and received from the DU. -Next steps: handling of UE context modification request at the DU and triggering the UE context setup response towards the CU. --- openair2/COMMON/f1ap_messages_def.h | 2 + openair2/COMMON/f1ap_messages_types.h | 10 +- openair2/F1AP/f1ap_cu_task.c | 6 + openair2/F1AP/f1ap_cu_ue_context_management.c | 402 +++++++++++++++--- openair2/F1AP/f1ap_cu_ue_context_management.h | 3 +- openair2/F1AP/f1ap_decoder.c | 4 + openair2/RRC/NR/rrc_gNB.c | 4 + openair2/RRC/NR/rrc_gNB_NGAP.c | 46 +- 8 files changed, 414 insertions(+), 63 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_def.h b/openair2/COMMON/f1ap_messages_def.h index 0e857f3a83..f28e0e5ddf 100644 --- a/openair2/COMMON/f1ap_messages_def.h +++ b/openair2/COMMON/f1ap_messages_def.h @@ -46,6 +46,8 @@ MESSAGE_DEF(F1AP_DL_RRC_MESSAGE , MESSAGE_PRIORITY_MED, f1ap_dl_rrc //MESSAGE_DEF(F1AP_INITIAL_CONTEXT_SETUP_REQ , MESSAGE_PRIORITY_MED, f1ap_initial_context_setup_req_t , f1ap_initial_context_setup_req ) MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_REQ, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_setup_req) MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_RESP, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_setup_resp) +MESSAGE_DEF(F1AP_UE_CONTEXT_MODIFICATION_REQ, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_modification_req) +MESSAGE_DEF(F1AP_UE_CONTEXT_MODIFICATION_RESP, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_modification_resp) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 7116dd09c1..3a5b95408b 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -39,15 +39,15 @@ #define F1AP_INITIAL_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_initial_ul_rrc_message #define F1AP_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ul_rrc_message #define F1AP_UE_CONTEXT_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_req -#define F1AP_UE_CONTEXT_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_resp +#define F1AP_UE_CONTEXT_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_resp #define F1AP_UE_CONTEXT_RELEASE_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_release_resp +#define F1AP_UE_CONTEXT_MODIFICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_req #define F1AP_UE_CONTEXT_MODIFICATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_resp #define F1AP_UE_CONTEXT_MODIFICATION_FAIL(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_fail #define F1AP_DL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_dl_rrc_message #define F1AP_UE_CONTEXT_RELEASE_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_release_req #define F1AP_UE_CONTEXT_RELEASE_CMD(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_release_req -#define F1AP_UE_CONTEXT_MODIFICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_req /* Length of the transport layer address string * 160 bits / 8 bits by char. @@ -352,6 +352,11 @@ typedef struct cu_to_du_rrc_information_s { uint8_t measConfig_length; }cu_to_du_rrc_information_t; +typedef enum QoS_information_e { + NG_RAN_QoS = 0, + EUTRAN_QoS = 1, +} QoS_information_t; + typedef struct f1ap_ue_context_setup_s { uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti uint32_t gNB_DU_ue_id; @@ -370,6 +375,7 @@ typedef struct f1ap_ue_context_setup_s { uint8_t du_to_cu_rrc_information_length; f1ap_drb_to_be_setup_t *drbs_to_be_setup; // BK: need to replace by s1ap_initial_context_setup_req uint8_t drbs_to_be_setup_length; // BK: need to replace by s1ap_initial_context_setup_req + QoS_information_t QoS_information_type; uint8_t drbs_failed_to_be_setup_length; f1ap_rb_failed_to_be_setup_t *drbs_failed_to_be_setup; f1ap_srb_to_be_setup_t *srbs_to_be_setup; diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c index fbe0508f60..2ed80367f9 100644 --- a/openair2/F1AP/f1ap_cu_task.c +++ b/openair2/F1AP/f1ap_cu_task.c @@ -180,6 +180,12 @@ void * F1AP_CU_task(void *arg) { &F1AP_UE_CONTEXT_SETUP_REQ(received_msg)); break; + case F1AP_UE_CONTEXT_MODIFICATION_REQ: + LOG_I(F1AP, "CU Task received F1AP_UE_CONTEXT_MODIFICATION_REQ\n"); + CU_send_UE_CONTEXT_MODIFICATION_REQUEST(ITTI_MSG_DESTINATION_INSTANCE(received_msg), + &F1AP_UE_CONTEXT_MODIFICATION_REQ(received_msg)); + break; + case F1AP_UE_CONTEXT_RELEASE_CMD: // from rrc LOG_I(F1AP, "CU Task Received F1AP_UE_CONTEXT_RELEASE_CMD\n"); CU_send_UE_CONTEXT_RELEASE_COMMAND(ITTI_MSG_DESTINATION_INSTANCE(received_msg), diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 0b72b2b5a4..40cac2398f 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1016,7 +1016,7 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, return 0; } //void CU_send_UE_CONTEXT_MODIFICATION_REQUEST(F1AP_UEContextModificationRequest_t *UEContextModificationRequest) { -int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { +int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context_setup_t *f1ap_ue_context_modification_req) { F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextModificationRequest_t *out; uint8_t *buffer=NULL; @@ -1037,14 +1037,14 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ie1->criticality = F1AP_Criticality_reject; ie1->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie1->value.choice.GNB_CU_UE_F1AP_ID = 126L; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, f1ap_ue_context_modification_req->rnti);; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie2); ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie2->criticality = F1AP_Criticality_reject; ie2->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie2->value.choice.GNB_DU_UE_F1AP_ID = 651L; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, f1ap_ue_context_modification_req->rnti);; /* optional */ /* c3. NRCGI */ @@ -1057,13 +1057,15 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { addnRCGI(ie3->value.choice.NRCGI, &hardCoded); } - /* mandatory */ + /* optional */ /* c4. ServCellIndex */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie4); - ie4->id = F1AP_ProtocolIE_ID_id_ServCellIndex; - ie4->criticality = F1AP_Criticality_reject; - ie4->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ServCellIndex; - ie4->value.choice.ServCellIndex = 5L; + if(0){ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_ServCellIndex; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ServCellIndex; + ie4->value.choice.ServCellIndex = 5L; + } /* optional */ /* c5. DRXCycle */ @@ -1076,7 +1078,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { if (0) { asn1cCallocOne(ie5->value.choice.DRXCycle.shortDRXCycleLength, - F1AP_ShortDRXCycleLength_ms2); // enum + F1AP_ShortDRXCycleLength_ms2); // enum } if (0) { @@ -1086,25 +1088,36 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* optional */ /* c5. CUtoDURRCInformation */ - if (1) { + if (f1ap_ue_context_modification_req->cu_to_du_rrc_information!=NULL) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie5); ie5->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; ie5->criticality = F1AP_Criticality_reject; ie5->value.present = F1AP_UEContextModificationRequestIEs__value_PR_CUtoDURRCInformation; - asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.cG_ConfigInfo, tmp); + /* 6.1 cG_ConfigInfo */ + if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->cG_ConfigInfo!=NULL){ + const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; + asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.cG_ConfigInfo, cG_ConfigInfo); + OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen(cG_ConfigInfoStr)) ; + } /* optional */ - OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, - tmp2); + /* 6.2 uE_CapabilityRAT_ContainerList */ + if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ + asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); + OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, (const char *)f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, + f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length) ; + } /* optional */ - OCTET_STRING_fromBuf(tmp2, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + /* 6.3 measConfig */ + if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->measConfig!=NULL){ + const char measConfigStr[]="asdsa1d32sa1d31asd31as"; + asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.measConfig, measConfig); + OCTET_STRING_fromBuf(measConfig, measConfigStr, strlen(measConfigStr)) ; + } } /* optional */ /* c6. TransmissionActionIndicator */ - if (1) { + if (0) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie6); ie6->id = F1AP_ProtocolIE_ID_id_TransmissionActionIndicator; ie6->criticality = F1AP_Criticality_ignore; @@ -1125,7 +1138,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* optional */ /* c7. RRCRconfigurationCompleteIndicator */ - if (1) { + if (0) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie71); ie71->id = F1AP_ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator; ie71->criticality = F1AP_Criticality_ignore; @@ -1135,7 +1148,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* optional */ /* c8. RRCContainer */ - if (1) { + if (0) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie8); ie8->id = F1AP_ProtocolIE_ID_id_RRCContainer; ie8->criticality = F1AP_Criticality_ignore; @@ -1144,8 +1157,9 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { strlen("asdsa1d32sa1d31asd31as")); } - /* mandatory */ + /* optional */ /* c9. SCell_ToBeSetupMod_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie9); ie9->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_List; ie9->criticality = F1AP_Criticality_ignore; @@ -1166,9 +1180,11 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* sCellIndex */ scell_toBeSetupMod_item->sCellIndex = 6; // issue here } + } - /* mandatory */ + /* optional */ /* c10. SCell_ToBeRemoved_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie10); ie10->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_List; ie10->criticality = F1AP_Criticality_ignore; @@ -1189,37 +1205,44 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* - sCell_ID */ addnRCGI(scell_toBeRemoved_item->sCell_ID, &hardCoded); } + } /* mandatory */ /* c11. SRBs_ToBeSetupMod_List */ + if(f1ap_ue_context_modification_req->srbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie11); ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List; ie11->criticality = F1AP_Criticality_reject; ie11->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeSetupMod_List; - for (int i=0; i<1; i++) { + for (int i=0; isrbs_to_be_setup_length; i++) { // - asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetupMod_List.list, - F1AP_SRBs_ToBeSetupMod_ItemIEs_t, srbs_toBeSetupMod_item_ies); - srbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_Item; - srbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; + asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetupMod_List, F1AP_SRBs_ToBeSetupMod_ItemIEs_t, srbs_toBeSetupMod_item_ies); + srbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_Item; // 73 + srbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; srbs_toBeSetupMod_item_ies->value.present = F1AP_SRBs_ToBeSetupMod_ItemIEs__value_PR_SRBs_ToBeSetupMod_Item; - /* 9.1 SRBs_ToBeSetupMod_Item */ - F1AP_SRBs_ToBeSetupMod_Item_t *srbs_toBeSetupMod_item= - &srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item; - /* - sRBID */ - srbs_toBeSetupMod_item->sRBID = 3L; + /* 11.1 SRBs_ToBeSetup_Item */ + F1AP_SRBs_ToBeSetupMod_Item_t *srbs_toBeSetupMod_item=&srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item; + /* 11.1.1 sRBID */ + srbs_toBeSetupMod_item->sRBID = f1ap_ue_context_modification_req->srbs_to_be_setup[i].srb_id; + /* OPTIONAL */ + /* 11.1.2 duplicationIndication */ + //if (0) { + asn1cCallocOne(srbs_toBeSetupMod_item->duplicationIndication, + F1AP_DuplicationIndication_true); // enum + //} + } } /* mandatory */ /* c12. DRBs_ToBeSetupMod_List */ + if(f1ap_ue_context_modification_req->drbs_to_be_setup_length){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie12); ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; ie12->criticality = F1AP_Criticality_reject; ie12->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List; - for (int i=0; i<1; i++) { - // + for (int i = 0; i < f1ap_ue_context_modification_req->drbs_to_be_setup_length; i++) { asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetupMod_List.list, F1AP_DRBs_ToBeSetupMod_ItemIEs_t, drbs_toBeSetupMod_item_ies); drbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item; @@ -1229,39 +1252,295 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { F1AP_DRBs_ToBeSetupMod_Item_t *drbs_toBeSetupMod_item= &drbs_toBeSetupMod_item_ies->value.choice.DRBs_ToBeSetupMod_Item; /* dRBID */ - drbs_toBeSetupMod_item->dRBID = 30L; + drbs_toBeSetupMod_item->dRBID = f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id; /* qoSInformation */ - drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; - drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS->qCI = 253L; - /* uLUPTNLInformation_ToBeSetup_List */ - int maxnoofULTunnels = 1; // 2; - for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, + if(f1ap_ue_context_modification_req->QoS_information_type == EUTRAN_QoS){ + drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS->qCI = 253L; + /* uLUPTNLInformation_ToBeSetup_List */ + int maxnoofULTunnels = 1; // 2; + + for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, gTPTunnel) - /* transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - /* gTP_TEID */ - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", - strlen("4567")); + /* transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", + strlen("4567")); } - /* rLCMode */ - drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum + /* rLCMode */ + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum + + /* OPTIONAL */ + /* ULConfiguration */ + if (0) { + drbs_toBeSetupMod_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + } + } //QoS information + + else{ + /* 12.1.2 DRB_Information */ + drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; + F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); + ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; + F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; + drbs_toBeSetupMod_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; + /* 12.1.2.1 dRB_QoS */ + { + /* qoS_Characteristics */ + { + int some_decide_qoS_characteristics = 0; // BK: Need Check + + if (some_decide_qoS_characteristics) { + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); + } else { + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; + + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); + } + + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); + } + + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); + } + } // if some_decide_qoS_characteristics + + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority + + /* OPTIONAL */ + /* gBR_QoS_Flow_Information */ + if (0) { + asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); + + /* OPTIONAL */ + /* maxPacketLossRateDownlink */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + } + + /* OPTIONAL */ + /* maxPacketLossRateUplink */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + } + } + + /* OPTIONAL */ + /* reflective_QoS_Attribute */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); + } + } // dRB_QoS + /* 12.1.2.2 sNSSAI */ + { + /* sST */ + + OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); + + /* OPTIONAL */ + /* sD */ + if (0) { + asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", + strlen("asdsa1d32sa1d31asd31as")); + } + } /* OPTIONAL */ - /* ULConfiguration */ + /* 12.1.2.3 notificationControl */ if (0) { - drbs_toBeSetupMod_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + asn1cCallocOne(DRB_Information->notificationControl, + F1AP_NotificationControl_active); // enum + } + + /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy + + for (int k = 0; k < 1; k ++) { + asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, + F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); + /* qoSFlowIndicator */ + flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; + /* qoSFlowLevelQoSParameters */ + { + /* qoS_Characteristics */ + { + int some_decide_qoS_characteristics = 0; // BK: Need Check + F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; + + if (some_decide_qoS_characteristics) { + QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(QosParams->choice.non_Dynamic_5QI); + } else { + QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; + + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); + *tmp= 1L; + } + } // if some_decide_qoS_characteristics + + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority + + /* OPTIONAL */ + /* gBR_QoS_Flow_Information */ + if (0) { + asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); + + /* OPTIONAL */ + /* maxPacketLossRateDownlink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + } + + /* OPTIONAL */ + /* maxPacketLossRateUplink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + } + } + + /* OPTIONAL */ + /* reflective_QoS_Attribute */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); + } + } // qoSFlowLevelQoSParameters + } + + } //QoS information + + /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ + for (int j = 0; j < f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { + /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ + transport_layer_addr_t addr; + int sz=sizeof(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); + memcpy(addr.buffer,&f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); + addr.length = sz*8; + + f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= + newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_modification_req->rnti, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, + 0xFFFF, // We will set the right value from DU answer + addr, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].port, + cu_f1u_data_req); + /* 12.3.1 ULTunnels_ToBeSetup_Item */ + asn1cSequenceAdd(drbs_toBeSetupMod_item->uLUPTNLInformation_ToBeSetup_List.list, + F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + gTPTunnel); + /* 12.3.1.1.1 transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, + &gTPTunnel->transportLayerAddress); + /* 12.3.1.1.2 gTP_TEID */ + INT32_TO_OCTET_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, + &gTPTunnel->gTP_TEID); + } + /* 12.1.4 rLCMode */ + /* TODO use rlc_mode from f1ap_drb_to_be_setup */ + switch (f1ap_ue_context_modification_req->drbs_to_be_setup[i].rlc_mode) { + case RLC_MODE_AM: + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_am; + break; + + default: + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; + } + + /* OPTIONAL */ + /* 12.1.5 ULConfiguration */ + if (0) { + asn1cCalloc(drbs_toBeSetupMod_item->uLConfiguration, tmp); + tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; + } + + /* OPTIONAL */ + /* 12.1.6 duplicationActivation */ + if (0) { + asn1cCalloc(drbs_toBeSetupMod_item->duplicationActivation, tmp); + *tmp = F1AP_DuplicationActivation_active; // enum } } + } - /* mandatory */ + /* optional */ + if(0){ /* c13. DRBs_ToBeModified_List */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie13); ie13->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_List; @@ -1306,8 +1585,10 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { drbs_toBeModified_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); } } + } - /* mandatory */ + /* optional */ + if(0){ /* c14. SRBs_ToBeReleased_List */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie14); ie14->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_List; @@ -1327,8 +1608,10 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* - sRBID */ srbs_toBeReleased_item->sRBID = 2L; } + } - /* mandatory */ + /* optional */ + if(0){ /* c15. DRBs_ToBeReleased_List */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie15); ie15->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_List; @@ -1348,13 +1631,14 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { /* dRBID */ drbs_toBeReleased_item->dRBID = 30L; } + } /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 UE CONTEXT_MODIFICATION REQUEST\n"); return -1; } - + f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0 /* BK: fix me*/); return 0; } diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.h b/openair2/F1AP/f1ap_cu_ue_context_management.h index 09af51ec54..87563e97b1 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.h +++ b/openair2/F1AP/f1ap_cu_ue_context_management.h @@ -72,7 +72,8 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, /* * UE Context Modification (gNB-CU initiated) */ -int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance); +int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, + f1ap_ue_context_setup_t *f1ap_ue_context_modification_req); int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, uint32_t assoc_id, uint32_t stream, diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index 6ebf1cc16d..f1e4410786 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -78,6 +78,10 @@ static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) { case F1AP_ProcedureCode_id_UEContextSetup: LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextSetup\n", __func__); break; + + case F1AP_ProcedureCode_id_UEContextModification: + LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextModification\n", __func__); + break; // case F1AP_ProcedureCode_id_InitialContextSetup: // res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_F1AP_F1AP_PDU, pdu); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 0208cc4a57..f91d2a9ad0 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3979,6 +3979,10 @@ void *rrc_gnb_task(void *args_p) { rrc_CU_process_ue_context_setup_response(msg_p, msg_name_p, instance); break; + case F1AP_UE_CONTEXT_MODIFICATION_REQ: + LOG_I(NR_RRC, "F1AP_UE_CONTEXT_MODIFICATION_REQ itti message received from the F1AP layer of the DU \n"); + break; + /* Messages from X2AP */ case X2AP_ENDC_SGNB_ADDITION_REQ: LOG_I(NR_RRC, "Received ENDC sgNB addition request from X2AP \n"); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 7b2fb5ac10..69d3e4a52b 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1111,7 +1111,51 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( // TEST // ue_context_p->ue_context.pdusession[0].status = PDU_SESSION_STATUS_DONE; // rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(&ctxt, ue_context_p, 0); - rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, NULL); + if(!NODE_IS_CU(RC.nrrrc[ctxt.module_id]->node_type)){ + rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, NULL); + } + else{ + /*Generate a UE context modification request message towards the DU to instruct the DU + *for SRB2 and DRB configuration and get the updates on master cell group config from the DU*/ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_MODIFICATION_REQ); + f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_MODIFICATION_REQ (message_p); + //UE_IDs will be extracted from F1AP layer + req->gNB_CU_ue_id = 0; + req->gNB_DU_ue_id = 0; + req->rnti = ue_context_p->ue_context.rnti; + req->mcc = RC.nrrrc[ctxt.module_id]->configuration.mcc[0]; + req->mnc = RC.nrrrc[ctxt.module_id]->configuration.mnc[0]; + req->mnc_digit_length = RC.nrrrc[ctxt.module_id]->configuration.mnc_digit_length[0]; + req->nr_cellid = RC.nrrrc[ctxt.module_id]->nr_cellid; + + //if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { + /*Instruction towards the DU for SRB2 configuration*/ + req->srbs_to_be_setup = malloc(1*sizeof(f1ap_srb_to_be_setup_t)); + req->srbs_to_be_setup_length = 1; + f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; + SRBs[0].srb_id = 2; + SRBs[0].lcid = 2; + + /*Instruction towards the DU for DRB configuration and tunnel creation*/ + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; + memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); + req->drbs_to_be_setup = malloc(1*sizeof(f1ap_drb_to_be_setup_t)); + req->drbs_to_be_setup_length = 1; + f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; + LOG_I(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length); + DRBs[0].drb_id = 1; + DRBs[0].rlc_mode = RLC_MODE_AM; + DRBs[0].up_ul_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.my_addr); + DRBs[0].up_ul_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.my_portd; + DRBs[0].up_ul_tnl_length = 1; + DRBs[0].up_dl_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.remote_addr); + DRBs[0].up_dl_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.remote_portd; + DRBs[0].up_dl_tnl_length = 1; + //} + + itti_send_msg_to_task (TASK_CU_F1, ctxt.module_id, message_p); + } return(0); } } From b3c0095f0726e5db0f6f794ad8e474733c6ba9a5 Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 5 Oct 2021 17:24:16 +0200 Subject: [PATCH 04/84] Add handler function for UE context modification request message at F1AP layer of the DU -Fix indentation in UE context modification request message generation function at the CU --- openair2/COMMON/f1ap_messages_types.h | 6 + openair2/F1AP/f1ap_cu_ue_context_management.c | 744 +++++++++--------- openair2/F1AP/f1ap_du_ue_context_management.c | 151 +++- openair2/F1AP/f1ap_handlers.c | 2 +- 4 files changed, 529 insertions(+), 374 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 3a5b95408b..2881910b19 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -357,6 +357,11 @@ typedef enum QoS_information_e { EUTRAN_QoS = 1, } QoS_information_t; +typedef enum ReconfigurationCompl_e { + RRCreconf_failure = 0, + RRCreconf_success = 1, +} ReconfigurationCompl_t; + typedef struct f1ap_ue_context_setup_s { uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti uint32_t gNB_DU_ue_id; @@ -383,6 +388,7 @@ typedef struct f1ap_ue_context_setup_s { uint8_t srbs_failed_to_be_setup_length; f1ap_rb_failed_to_be_setup_t *srbs_failed_to_be_setup; s1ap_initial_context_setup_req_t *s1ap_initial_context_setup_req; + ReconfigurationCompl_t ReconfigComplOutcome; // coniatner for the rrc_eNB_generate_SecurityModeCommand message uint8_t *rrc_container; int rrc_container_length; diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 40cac2398f..087d63d3f1 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1160,338 +1160,338 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context /* optional */ /* c9. SCell_ToBeSetupMod_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie9); - ie9->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_List; - ie9->criticality = F1AP_Criticality_ignore; - ie9->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_List; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeSetupMod_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie9->value.choice.SCell_ToBeSetupMod_List.list, + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie9->value.choice.SCell_ToBeSetupMod_List.list, F1AP_SCell_ToBeSetupMod_ItemIEs_t, scell_toBeSetupMod_item_ies); - scell_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_Item; - scell_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; - scell_toBeSetupMod_item_ies->value.present = F1AP_SCell_ToBeSetupMod_ItemIEs__value_PR_SCell_ToBeSetupMod_Item; - /* 8.1 SCell_ToBeSetup_Item */ - F1AP_SCell_ToBeSetupMod_Item_t *scell_toBeSetupMod_item= - &scell_toBeSetupMod_item_ies->value.choice.SCell_ToBeSetupMod_Item; - // /* - sCell_ID */ - addnRCGI(scell_toBeSetupMod_item->sCell_ID, &hardCoded); - /* sCellIndex */ - scell_toBeSetupMod_item->sCellIndex = 6; // issue here - } + scell_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_Item; + scell_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; + scell_toBeSetupMod_item_ies->value.present = F1AP_SCell_ToBeSetupMod_ItemIEs__value_PR_SCell_ToBeSetupMod_Item; + /* 8.1 SCell_ToBeSetup_Item */ + F1AP_SCell_ToBeSetupMod_Item_t *scell_toBeSetupMod_item= + &scell_toBeSetupMod_item_ies->value.choice.SCell_ToBeSetupMod_Item; + // /* - sCell_ID */ + addnRCGI(scell_toBeSetupMod_item->sCell_ID, &hardCoded); + /* sCellIndex */ + scell_toBeSetupMod_item->sCellIndex = 6; // issue here + } } /* optional */ /* c10. SCell_ToBeRemoved_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie10); - ie10->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_List; - ie10->criticality = F1AP_Criticality_ignore; - ie10->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeRemoved_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_List; + ie10->criticality = F1AP_Criticality_ignore; + ie10->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeRemoved_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie10->value.choice.SCell_ToBeRemoved_List.list, + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie10->value.choice.SCell_ToBeRemoved_List.list, F1AP_SCell_ToBeRemoved_ItemIEs_t, scell_toBeRemoved_item_ies); - scell_toBeRemoved_item_ies = (F1AP_SCell_ToBeRemoved_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); - //memset((void *)&scell_toBeRemoved_item_ies, 0, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); - scell_toBeRemoved_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_Item; - scell_toBeRemoved_item_ies->criticality = F1AP_Criticality_ignore; - scell_toBeRemoved_item_ies->value.present = F1AP_SCell_ToBeRemoved_ItemIEs__value_PR_SCell_ToBeRemoved_Item; - /* 10.1 SCell_ToBeRemoved_Item */ - F1AP_SCell_ToBeRemoved_Item_t *scell_toBeRemoved_item= - &scell_toBeRemoved_item_ies->value.choice.SCell_ToBeRemoved_Item; - /* - sCell_ID */ - addnRCGI(scell_toBeRemoved_item->sCell_ID, &hardCoded); - } + scell_toBeRemoved_item_ies = (F1AP_SCell_ToBeRemoved_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); + //memset((void *)&scell_toBeRemoved_item_ies, 0, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); + scell_toBeRemoved_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_Item; + scell_toBeRemoved_item_ies->criticality = F1AP_Criticality_ignore; + scell_toBeRemoved_item_ies->value.present = F1AP_SCell_ToBeRemoved_ItemIEs__value_PR_SCell_ToBeRemoved_Item; + /* 10.1 SCell_ToBeRemoved_Item */ + F1AP_SCell_ToBeRemoved_Item_t *scell_toBeRemoved_item= + &scell_toBeRemoved_item_ies->value.choice.SCell_ToBeRemoved_Item; + /* - sCell_ID */ + addnRCGI(scell_toBeRemoved_item->sCell_ID, &hardCoded); + } } /* mandatory */ /* c11. SRBs_ToBeSetupMod_List */ if(f1ap_ue_context_modification_req->srbs_to_be_setup_length > 0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie11); - ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List; - ie11->criticality = F1AP_Criticality_reject; - ie11->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List; + ie11->criticality = F1AP_Criticality_reject; + ie11->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeSetupMod_List; - for (int i=0; isrbs_to_be_setup_length; i++) { - // - asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetupMod_List, F1AP_SRBs_ToBeSetupMod_ItemIEs_t, srbs_toBeSetupMod_item_ies); - srbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_Item; // 73 - srbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; - srbs_toBeSetupMod_item_ies->value.present = F1AP_SRBs_ToBeSetupMod_ItemIEs__value_PR_SRBs_ToBeSetupMod_Item; - /* 11.1 SRBs_ToBeSetup_Item */ - F1AP_SRBs_ToBeSetupMod_Item_t *srbs_toBeSetupMod_item=&srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item; - /* 11.1.1 sRBID */ - srbs_toBeSetupMod_item->sRBID = f1ap_ue_context_modification_req->srbs_to_be_setup[i].srb_id; - /* OPTIONAL */ - /* 11.1.2 duplicationIndication */ - //if (0) { - asn1cCallocOne(srbs_toBeSetupMod_item->duplicationIndication, + for (int i=0; isrbs_to_be_setup_length; i++) { + // + asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetupMod_List, F1AP_SRBs_ToBeSetupMod_ItemIEs_t, srbs_toBeSetupMod_item_ies); + srbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_Item; // 73 + srbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; + srbs_toBeSetupMod_item_ies->value.present = F1AP_SRBs_ToBeSetupMod_ItemIEs__value_PR_SRBs_ToBeSetupMod_Item; + /* 11.1 SRBs_ToBeSetup_Item */ + F1AP_SRBs_ToBeSetupMod_Item_t *srbs_toBeSetupMod_item=&srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item; + /* 11.1.1 sRBID */ + srbs_toBeSetupMod_item->sRBID = f1ap_ue_context_modification_req->srbs_to_be_setup[i].srb_id; + /* OPTIONAL */ + /* 11.1.2 duplicationIndication */ + //if (0) { + asn1cCallocOne(srbs_toBeSetupMod_item->duplicationIndication, F1AP_DuplicationIndication_true); // enum - //} - } + //} + } } /* mandatory */ /* c12. DRBs_ToBeSetupMod_List */ if(f1ap_ue_context_modification_req->drbs_to_be_setup_length){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie12); - ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; - ie12->criticality = F1AP_Criticality_reject; - ie12->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; + ie12->criticality = F1AP_Criticality_reject; + ie12->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List; - for (int i = 0; i < f1ap_ue_context_modification_req->drbs_to_be_setup_length; i++) { - asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetupMod_List.list, + for (int i = 0; i < f1ap_ue_context_modification_req->drbs_to_be_setup_length; i++) { + asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetupMod_List.list, F1AP_DRBs_ToBeSetupMod_ItemIEs_t, drbs_toBeSetupMod_item_ies); - drbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item; - drbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; - drbs_toBeSetupMod_item_ies->value.present = F1AP_DRBs_ToBeSetupMod_ItemIEs__value_PR_DRBs_ToBeSetupMod_Item; - /* 12.1 DRBs_ToBeSetupMod_Item */ - F1AP_DRBs_ToBeSetupMod_Item_t *drbs_toBeSetupMod_item= - &drbs_toBeSetupMod_item_ies->value.choice.DRBs_ToBeSetupMod_Item; - /* dRBID */ - drbs_toBeSetupMod_item->dRBID = f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id; - /* qoSInformation */ + drbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item; + drbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; + drbs_toBeSetupMod_item_ies->value.present = F1AP_DRBs_ToBeSetupMod_ItemIEs__value_PR_DRBs_ToBeSetupMod_Item; + /* 12.1 DRBs_ToBeSetupMod_Item */ + F1AP_DRBs_ToBeSetupMod_Item_t *drbs_toBeSetupMod_item= + &drbs_toBeSetupMod_item_ies->value.choice.DRBs_ToBeSetupMod_Item; + /* dRBID */ + drbs_toBeSetupMod_item->dRBID = f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id; + /* qoSInformation */ - if(f1ap_ue_context_modification_req->QoS_information_type == EUTRAN_QoS){ - drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; - drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS->qCI = 253L; - /* uLUPTNLInformation_ToBeSetup_List */ - int maxnoofULTunnels = 1; // 2; + if(f1ap_ue_context_modification_req->QoS_information_type == EUTRAN_QoS){ + drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS->qCI = 253L; + /* uLUPTNLInformation_ToBeSetup_List */ + int maxnoofULTunnels = 1; // 2; - for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, + for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, gTPTunnel) - /* transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - /* gTP_TEID */ - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", + /* transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", strlen("4567")); - } - - /* rLCMode */ - drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum - - /* OPTIONAL */ - /* ULConfiguration */ - if (0) { - drbs_toBeSetupMod_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); - } - } //QoS information - - else{ - /* 12.1.2 DRB_Information */ - drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; - F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); - ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; - F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; - drbs_toBeSetupMod_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; - /* 12.1.2.1 dRB_QoS */ - { - /* qoS_Characteristics */ - { - int some_decide_qoS_characteristics = 0; // BK: Need Check - - if (some_decide_qoS_characteristics) { - DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); - } else { - DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); - /* qoSPriorityLevel */ - tmp->qoSPriorityLevel = 1L; - /* packetDelayBudget */ - tmp->packetDelayBudget = 1L; - /* packetErrorRate */ - tmp->packetErrorRate.pER_Scalar = 1L; - tmp->packetErrorRate.pER_Exponent = 6L; - - /* OPTIONAL */ - /* delayCritical */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); - } - - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); - } - - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); - } - } // if some_decide_qoS_characteristics - - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ - { - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum - } // nGRANallocationRetentionPriority - - /* OPTIONAL */ - /* gBR_QoS_Flow_Information */ - if (0) { - asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); - asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); - - /* OPTIONAL */ - /* maxPacketLossRateDownlink */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); } + /* rLCMode */ + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum + /* OPTIONAL */ - /* maxPacketLossRateUplink */ + /* ULConfiguration */ if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + drbs_toBeSetupMod_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); } - } + } //QoS information - /* OPTIONAL */ - /* reflective_QoS_Attribute */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); - } - } // dRB_QoS - /* 12.1.2.2 sNSSAI */ - { - /* sST */ - - OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); - - /* OPTIONAL */ - /* sD */ - if (0) { - asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - } - } - - /* OPTIONAL */ - /* 12.1.2.3 notificationControl */ - if (0) { - asn1cCallocOne(DRB_Information->notificationControl, - F1AP_NotificationControl_active); // enum - } - - /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy - - for (int k = 0; k < 1; k ++) { - asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, - F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); - /* qoSFlowIndicator */ - flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; - /* qoSFlowLevelQoSParameters */ - { - /* qoS_Characteristics */ + else{ + /* 12.1.2 DRB_Information */ + drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; + F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); + ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; + F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; + drbs_toBeSetupMod_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; + /* 12.1.2.1 dRB_QoS */ { - int some_decide_qoS_characteristics = 0; // BK: Need Check - F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; + /* qoS_Characteristics */ + { + int some_decide_qoS_characteristics = 0; // BK: Need Check - if (some_decide_qoS_characteristics) { - QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - setQos(QosParams->choice.non_Dynamic_5QI); - } else { - QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); - /* qoSPriorityLevel */ - tmp->qoSPriorityLevel = 1L; - /* packetDelayBudget */ - tmp->packetDelayBudget = 1L; - /* packetErrorRate */ - tmp->packetErrorRate.pER_Scalar = 1L; - tmp->packetErrorRate.pER_Exponent = 6L; + if (some_decide_qoS_characteristics) { + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); + } else { + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; - /* OPTIONAL */ - /* delayCritical */ - if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); - *tmp = 1L; - } + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); + } - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); - *tmp = 1L; - } + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); + } - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); - *tmp= 1L; - } - } // if some_decide_qoS_characteristics + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); + } + } // if some_decide_qoS_characteristics - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ - { - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum - } // nGRANallocationRetentionPriority + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority - /* OPTIONAL */ - /* gBR_QoS_Flow_Information */ - if (0) { - asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); - asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); + /* OPTIONAL */ + /* gBR_QoS_Flow_Information */ + if (0) { + asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); /* OPTIONAL */ /* maxPacketLossRateDownlink */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); } /* OPTIONAL */ /* maxPacketLossRateUplink */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); } } /* OPTIONAL */ /* reflective_QoS_Attribute */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); } - } // qoSFlowLevelQoSParameters - } + } // dRB_QoS + /* 12.1.2.2 sNSSAI */ + { + /* sST */ - } //QoS information + OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); - /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ - for (int j = 0; j < f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { - /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ - transport_layer_addr_t addr; - int sz=sizeof(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); - memcpy(addr.buffer,&f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); - addr.length = sz*8; + /* OPTIONAL */ + /* sD */ + if (0) { + asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", + strlen("asdsa1d32sa1d31asd31as")); + } + } - f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= - newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + /* OPTIONAL */ + /* 12.1.2.3 notificationControl */ + if (0) { + asn1cCallocOne(DRB_Information->notificationControl, + F1AP_NotificationControl_active); // enum + } + + /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy + + for (int k = 0; k < 1; k ++) { + asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, + F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); + /* qoSFlowIndicator */ + flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; + /* qoSFlowLevelQoSParameters */ + { + /* qoS_Characteristics */ + { + int some_decide_qoS_characteristics = 0; // BK: Need Check + F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; + + if (some_decide_qoS_characteristics) { + QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(QosParams->choice.non_Dynamic_5QI); + } else { + QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; + + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); + *tmp= 1L; + } + } // if some_decide_qoS_characteristics + + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority + + /* OPTIONAL */ + /* gBR_QoS_Flow_Information */ + if (0) { + asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); + + /* OPTIONAL */ + /* maxPacketLossRateDownlink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + } + + /* OPTIONAL */ + /* maxPacketLossRateUplink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + } + } + + /* OPTIONAL */ + /* reflective_QoS_Attribute */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); + } + } // qoSFlowLevelQoSParameters + } + + } //QoS information + + /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ + for (int j = 0; j < f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { + /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ + transport_layer_addr_t addr; + int sz=sizeof(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); + memcpy(addr.buffer,&f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); + addr.length = sz*8; + + f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= + newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, f1ap_ue_context_modification_req->rnti, f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, @@ -1499,138 +1499,138 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context addr, f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].port, cu_f1u_data_req); - /* 12.3.1 ULTunnels_ToBeSetup_Item */ - asn1cSequenceAdd(drbs_toBeSetupMod_item->uLUPTNLInformation_ToBeSetup_List.list, + /* 12.3.1 ULTunnels_ToBeSetup_Item */ + asn1cSequenceAdd(drbs_toBeSetupMod_item->uLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, gTPTunnel); - /* 12.3.1.1.1 transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, + /* 12.3.1.1.1 transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, &gTPTunnel->transportLayerAddress); - /* 12.3.1.1.2 gTP_TEID */ - INT32_TO_OCTET_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, + /* 12.3.1.1.2 gTP_TEID */ + INT32_TO_OCTET_STRING(f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, &gTPTunnel->gTP_TEID); - } - /* 12.1.4 rLCMode */ - /* TODO use rlc_mode from f1ap_drb_to_be_setup */ - switch (f1ap_ue_context_modification_req->drbs_to_be_setup[i].rlc_mode) { - case RLC_MODE_AM: - drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_am; - break; + } + /* 12.1.4 rLCMode */ + /* TODO use rlc_mode from f1ap_drb_to_be_setup */ + switch (f1ap_ue_context_modification_req->drbs_to_be_setup[i].rlc_mode) { + case RLC_MODE_AM: + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_am; + break; - default: - drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; - } + default: + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; + } - /* OPTIONAL */ - /* 12.1.5 ULConfiguration */ - if (0) { - asn1cCalloc(drbs_toBeSetupMod_item->uLConfiguration, tmp); - tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; - } + /* OPTIONAL */ + /* 12.1.5 ULConfiguration */ + if (0) { + asn1cCalloc(drbs_toBeSetupMod_item->uLConfiguration, tmp); + tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; + } - /* OPTIONAL */ - /* 12.1.6 duplicationActivation */ - if (0) { - asn1cCalloc(drbs_toBeSetupMod_item->duplicationActivation, tmp); - *tmp = F1AP_DuplicationActivation_active; // enum + /* OPTIONAL */ + /* 12.1.6 duplicationActivation */ + if (0) { + asn1cCalloc(drbs_toBeSetupMod_item->duplicationActivation, tmp); + *tmp = F1AP_DuplicationActivation_active; // enum + } } } - } /* optional */ if(0){ - /* c13. DRBs_ToBeModified_List */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie13); - ie13->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_List; - ie13->criticality = F1AP_Criticality_reject; - ie13->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List; + /* c13. DRBs_ToBeModified_List */ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie13); + ie13->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_List; + ie13->criticality = F1AP_Criticality_reject; + ie13->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd( ie13->value.choice.DRBs_ToBeModified_List.list, + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd( ie13->value.choice.DRBs_ToBeModified_List.list, F1AP_DRBs_ToBeModified_ItemIEs_t, drbs_toBeModified_item_ies); - drbs_toBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_Item; - drbs_toBeModified_item_ies->criticality = F1AP_Criticality_reject; - drbs_toBeModified_item_ies->value.present = F1AP_DRBs_ToBeModified_ItemIEs__value_PR_DRBs_ToBeModified_Item; - /* 13.1 SRBs_ToBeModified_Item */ - F1AP_DRBs_ToBeModified_Item_t *drbs_toBeModified_item= - &drbs_toBeModified_item_ies->value.choice.DRBs_ToBeModified_Item; - /* dRBID */ - drbs_toBeModified_item->dRBID = 30L; - /* qoSInformation */ - asn1cCalloc(drbs_toBeModified_item->qoSInformation, tmp); - tmp->present = F1AP_QoSInformation_PR_eUTRANQoS; - tmp->choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - tmp->choice.eUTRANQoS->qCI = 254L; - /* ULTunnels_ToBeModified_List */ - int maxnoofULTunnels = 1; // 2; + drbs_toBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_Item; + drbs_toBeModified_item_ies->criticality = F1AP_Criticality_reject; + drbs_toBeModified_item_ies->value.present = F1AP_DRBs_ToBeModified_ItemIEs__value_PR_DRBs_ToBeModified_Item; + /* 13.1 SRBs_ToBeModified_Item */ + F1AP_DRBs_ToBeModified_Item_t *drbs_toBeModified_item= + &drbs_toBeModified_item_ies->value.choice.DRBs_ToBeModified_Item; + /* dRBID */ + drbs_toBeModified_item->dRBID = 30L; + /* qoSInformation */ + asn1cCalloc(drbs_toBeModified_item->qoSInformation, tmp); + tmp->present = F1AP_QoSInformation_PR_eUTRANQoS; + tmp->choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); + tmp->choice.eUTRANQoS->qCI = 254L; + /* ULTunnels_ToBeModified_List */ + int maxnoofULTunnels = 1; // 2; - for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, + for (int j=0; juLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, gTPTunnel); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); - } + } - /* OPTIONAL */ - /* ULConfiguration */ - if (0) { - drbs_toBeModified_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + /* OPTIONAL */ + /* ULConfiguration */ + if (0) { + drbs_toBeModified_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + } } } - } /* optional */ if(0){ - /* c14. SRBs_ToBeReleased_List */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie14); - ie14->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_List; - ie14->criticality = F1AP_Criticality_reject; - ie14->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeReleased_List; + /* c14. SRBs_ToBeReleased_List */ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie14); + ie14->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_List; + ie14->criticality = F1AP_Criticality_reject; + ie14->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeReleased_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie14->value.choice.SRBs_ToBeReleased_List.list, + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie14->value.choice.SRBs_ToBeReleased_List.list, F1AP_SRBs_ToBeReleased_ItemIEs_t, srbs_toBeReleased_item_ies); - srbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_Item; - srbs_toBeReleased_item_ies->criticality = F1AP_Criticality_ignore; - srbs_toBeReleased_item_ies->value.present = F1AP_SRBs_ToBeReleased_ItemIEs__value_PR_SRBs_ToBeReleased_Item; - /* 9.1 SRBs_ToBeReleased_Item */ - F1AP_SRBs_ToBeReleased_Item_t *srbs_toBeReleased_item= - &srbs_toBeReleased_item_ies->value.choice.SRBs_ToBeReleased_Item; - /* - sRBID */ - srbs_toBeReleased_item->sRBID = 2L; - } + srbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_Item; + srbs_toBeReleased_item_ies->criticality = F1AP_Criticality_ignore; + srbs_toBeReleased_item_ies->value.present = F1AP_SRBs_ToBeReleased_ItemIEs__value_PR_SRBs_ToBeReleased_Item; + /* 9.1 SRBs_ToBeReleased_Item */ + F1AP_SRBs_ToBeReleased_Item_t *srbs_toBeReleased_item= + &srbs_toBeReleased_item_ies->value.choice.SRBs_ToBeReleased_Item; + /* - sRBID */ + srbs_toBeReleased_item->sRBID = 2L; + } } /* optional */ if(0){ - /* c15. DRBs_ToBeReleased_List */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie15); - ie15->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_List; - ie15->criticality = F1AP_Criticality_reject; - ie15->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeReleased_List; + /* c15. DRBs_ToBeReleased_List */ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie15); + ie15->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_List; + ie15->criticality = F1AP_Criticality_reject; + ie15->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeReleased_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie15->value.choice.DRBs_ToBeReleased_List.list, + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie15->value.choice.DRBs_ToBeReleased_List.list, F1AP_DRBs_ToBeReleased_ItemIEs_t, drbs_toBeReleased_item_ies); - drbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_Item; - drbs_toBeReleased_item_ies->criticality = F1AP_Criticality_reject; - drbs_toBeReleased_item_ies->value.present = F1AP_DRBs_ToBeReleased_ItemIEs__value_PR_DRBs_ToBeReleased_Item; - /* 14.1 SRBs_ToBeReleased_Item */ - F1AP_DRBs_ToBeReleased_Item_t *drbs_toBeReleased_item= - &drbs_toBeReleased_item_ies->value.choice.DRBs_ToBeReleased_Item; - /* dRBID */ - drbs_toBeReleased_item->dRBID = 30L; - } + drbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_Item; + drbs_toBeReleased_item_ies->criticality = F1AP_Criticality_reject; + drbs_toBeReleased_item_ies->value.present = F1AP_DRBs_ToBeReleased_ItemIEs__value_PR_DRBs_ToBeReleased_Item; + /* 14.1 SRBs_ToBeReleased_Item */ + F1AP_DRBs_ToBeReleased_Item_t *drbs_toBeReleased_item= + &drbs_toBeReleased_item_ies->value.choice.DRBs_ToBeReleased_Item; + /* dRBID */ + drbs_toBeReleased_item->dRBID = 30L; + } } /* encode */ diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index f779637d7e..cbbe563285 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -907,8 +907,157 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - AssertFatal(1==0,"Not implemented yet\n"); + + MessageDef *msg_p; // message to RRC + F1AP_UEContextModificationRequest_t *container; + int i; + DevAssert(pdu); + msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_MODIFICATION_REQ); + f1ap_ue_context_setup_t *f1ap_ue_context_modification_req = &F1AP_UE_CONTEXT_MODIFICATION_REQ(msg_p); + container = &pdu->choice.initiatingMessage->value.choice.UEContextModificationRequest; + + /* mandatory */ + /* GNB_CU_UE_F1AP_ID */ + F1AP_UEContextModificationRequestIEs_t *ieCU; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieCU, container, + F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); + f1ap_ue_context_modification_req->gNB_CU_ue_id = ieCU->value.choice.GNB_CU_UE_F1AP_ID; + + /* mandatory */ + /* GNB_DU_UE_F1AP_ID */ + F1AP_UEContextSetupRequestIEs_t *ieDU_UE; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDU_UE, container, + F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); + f1ap_ue_context_modification_req->gNB_DU_ue_id = ieDU_UE->value.choice.GNB_DU_UE_F1AP_ID; + f1ap_ue_context_modification_req->rnti = f1ap_get_rnti_by_du_id(DUtype, instance, f1ap_ue_context_modification_req->gNB_DU_ue_id); + + if(f1ap_ue_context_modification_req->rnti<0) + LOG_E(F1AP, "Could not retrieve UE rnti based on the DU UE id \n"); + else + LOG_I(F1AP, "Retrieved rnti is: %d \n", f1ap_ue_context_modification_req->rnti); + + /* SRB */ + F1AP_UEContextModificationRequestIEs_t *ieSrb; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieSrb, container, + F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List, false); + + if(ieSrb != NULL) { + f1ap_ue_context_modification_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetupMod_List.list.count; + f1ap_ue_context_modification_req->srbs_to_be_setup = calloc(f1ap_ue_context_modification_req->srbs_to_be_setup_length, + sizeof(f1ap_srb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_req->srbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_req->srbs_to_be_setup\n"); + + for (i = 0; i < f1ap_ue_context_modification_req->srbs_to_be_setup_length; ++i) { + f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_modification_req->srbs_to_be_setup[i]; + F1AP_SRBs_ToBeSetupMod_Item_t *srbs_tobesetupmod_item_p; + srbs_tobesetupmod_item_p = &((F1AP_SRBs_ToBeSetupMod_ItemIEs_t *)ieSrb->value.choice.SRBs_ToBeSetupMod_List.list.array[i])->value.choice.SRBs_ToBeSetupMod_Item; + srb_p->srb_id = srbs_tobesetupmod_item_p->sRBID; + } + } + + /* DRB */ + F1AP_UEContextModificationRequestIEs_t *ieDrb; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieDrb, container, + F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, false); + + if(ieDrb!=NULL) { + f1ap_ue_context_modification_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetupMod_List.list.count; + f1ap_ue_context_modification_req->drbs_to_be_setup = calloc(f1ap_ue_context_modification_req->drbs_to_be_setup_length, + sizeof(f1ap_drb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_req->drbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n"); + + for (i = 0; i < f1ap_ue_context_modification_req->drbs_to_be_setup_length; ++i) { + f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_modification_req->drbs_to_be_setup[i]; + F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p = + &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetupMod_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item; + drb_p->drb_id = drbs_tobesetup_item_p->dRBID; + /* TODO in the following, assume only one UP UL TNL is present. + * this matches/assumes OAI CU implementation, can be up to 2! */ + drb_p->up_ul_tnl_length = 1; + AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0, + "no UL UP TNL Information in DRBs to be Setup list\n"); + F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0]; + F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel; + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address); + OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid); + + switch (drbs_tobesetup_item_p->rLCMode) { + case F1AP_RLCMode_rlc_am: + drb_p->rlc_mode = RLC_MODE_AM; + break; + + default: + drb_p->rlc_mode = RLC_MODE_TM; + break; + } + if (!(RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU)) { + transport_layer_addr_t addr; + memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address)); + addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8; + drb_p->up_dl_tnl[0].teid=newGtpuCreateTunnel(INSTANCE_DEFAULT, + f1ap_ue_context_modification_req->rnti, + drb_p->drb_id, + drb_p->drb_id, + drb_p->up_ul_tnl[0].teid, + addr, + 2152, + lteDURecvCb); + drb_p->up_dl_tnl_length++; + } + } + } + /* RRC Reconfiguration Complete indicator */ + F1AP_UEContextModificationRequestIEs_t *ieReconf; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieReconf, container, + F1AP_ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator, false); + + if(ieReconf) { + switch(ieReconf->value.choice.RRCReconfigurationCompleteIndicator){ + case F1AP_RRCReconfigurationCompleteIndicator_true: + f1ap_ue_context_modification_req->ReconfigComplOutcome = RRCreconf_success; + break; + + case F1AP_RRCReconfigurationCompleteIndicator_failure: + f1ap_ue_context_modification_req->ReconfigComplOutcome = RRCreconf_failure; + break; + } + } + + /* RRCContainer */ + F1AP_UEContextModificationRequestIEs_t *ieRRC; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieRRC, container, + F1AP_ProtocolIE_ID_id_RRCContainer, false); + + if (ieRRC) { + /* correct here */ + if ( ieRRC->value.choice.RRCContainer.size ) { + f1ap_ue_context_modification_req->rrc_container = malloc(ieRRC->value.choice.RRCContainer.size); + memcpy(f1ap_ue_context_modification_req->rrc_container, + ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); + // AssertFatal(0, "check configuration, send to appropriate handler\n"); + protocol_ctxt_t ctxt; + // decode RRC Container and act on the message type + //FIXME + //rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + ctxt.instance = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + mem_block_t *pdcp_pdu_p = get_free_mem_block(ieRRC->value.choice.RRCContainer.size, __func__); + memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); + du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p); + } else { + LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n"); + } + } else { + LOG_W(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); + } + + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); + return 0; } + //void DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(F1AP_UEContextModificationResponse_t *UEContextModificationResponse) { int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { F1AP_F1AP_PDU_t pdu= {0}; diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index fec03bb0b9..6bbf1c796d 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -50,7 +50,7 @@ f1ap_message_processing_t f1ap_messages_processing[][3] = { { DU_handle_gNB_CU_CONFIGURATION_UPDATE, CU_handle_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE, CU_handle_gNB_CU_CONFIGURATION_UPDATE_FAILURE }, /* gNBCUConfigurationUpdate */ { DU_handle_UE_CONTEXT_SETUP_REQUEST, CU_handle_UE_CONTEXT_SETUP_RESPONSE, 0 }, /* UEContextSetup */ { DU_handle_UE_CONTEXT_RELEASE_COMMAND, CU_handle_UE_CONTEXT_RELEASE_COMPLETE, 0 }, /* UEContextRelease */ - { 0, 0, 0 }, /* UEContextModification */ + { DU_handle_UE_CONTEXT_MODIFICATION_REQUEST, 0, 0 }, /* UEContextModification */ { 0, 0, 0 }, /* UEContextModificationRequired */ { 0, 0, 0 }, /* UEMobilityCommand */ { CU_handle_UE_CONTEXT_RELEASE_REQUEST, 0, 0 }, /* UEContextReleaseRequest */ From f068fb4ef31b81af21ade6480b1bd2d3c238a1b3 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 6 Oct 2021 18:43:10 +0200 Subject: [PATCH 05/84] Add handling of UE context modification request at RRC layer of the DU and trigger UE context modification response -Next step: Proper generation of UE context modification response at F1AP layer --- openair2/COMMON/f1ap_messages_types.h | 5 +- openair2/F1AP/f1ap_du_task.c | 5 + openair2/RRC/NR/rrc_gNB.c | 157 +++++++++++++++++++++++--- 3 files changed, 151 insertions(+), 16 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 2881910b19..ecf5307dc0 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -358,8 +358,9 @@ typedef enum QoS_information_e { } QoS_information_t; typedef enum ReconfigurationCompl_e { - RRCreconf_failure = 0, - RRCreconf_success = 1, + RRCreconf_info_not_present = 0, + RRCreconf_failure = 1, + RRCreconf_success = 2, } ReconfigurationCompl_t; typedef struct f1ap_ue_context_setup_s { diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 6c5094d248..915858d7da 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -209,6 +209,11 @@ void *F1AP_DU_task(void *arg) { DU_send_UE_CONTEXT_SETUP_RESPONSE(myInstance, &F1AP_UE_CONTEXT_SETUP_RESP(msg)); break; + case F1AP_UE_CONTEXT_MODIFICATION_RESP: + LOG_I(F1AP, "DU task received itti message from RRC for F1AP_UE_CONTEXT_MODIFICATION_RESP message generation \n"); + //DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(myInstance, &F1AP_UE_CONTEXT_MODIFICATION_RESP(msg)); + break; + case F1AP_UE_CONTEXT_RELEASE_REQ: // from MAC LOG_I(F1AP, "DU Task Received F1AP_UE_CONTEXT_RELEASE_REQ\n"); DU_send_UE_CONTEXT_RELEASE_REQUEST(myInstance, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index f91d2a9ad0..92c6fe62d4 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3318,8 +3318,6 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha } } - - NR_CellGroupConfig_t *cellGroupConfig; cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); update_cellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup); @@ -3426,6 +3424,137 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); } +static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, const char *msg_name, instance_t instance){ + + f1ap_ue_context_setup_t * req=&F1AP_UE_CONTEXT_MODIFICATION_REQ(msg_p); + protocol_ctxt_t ctxt; + ctxt.rnti = req->rnti; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + gNB_MAC_INST *mac = RC.nrmac[ctxt.module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = + rrc_gNB_get_ue_context(rrc, ctxt.rnti); + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_MODIFICATION_RESP); + f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_MODIFICATION_RESP(message_p); + uint32_t incoming_teid = 0; + NR_CellGroupConfig_t *cellGroupConfig = NULL; + + /* Configure SRB2 */ + NR_SRB_ToAddMod_t *SRB2_config = NULL; + NR_SRB_ToAddModList_t *SRB_configList = NULL; + uint8_t SRBs_before_new_addition = 0; + + if(req->srbs_to_be_setup_length>0){ + if(ue_context_p->ue_context.SRB_configList == NULL){ + LOG_W(NR_RRC, "The SRB list of the UE context is empty before the addition of new SRB at the DU \n"); + ue_context_p->ue_context.SRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.SRB_configList)); + } + SRB_configList = ue_context_p->ue_context.SRB_configList; + SRBs_before_new_addition = SRB_configList->list.count; + for (int i=0; isrbs_to_be_setup_length; i++){ + SRB2_config = CALLOC(1, sizeof(*SRB2_config)); + SRB2_config->srb_Identity = req->srbs_to_be_setup[i].srb_id; + ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); + } + } + + /* Configure DRB */ + NR_DRB_ToAddMod_t *DRB_config = NULL; + NR_DRB_ToAddModList_t *DRB_configList = NULL; + if(req->drbs_to_be_setup_length>0){ + if(ue_context_p->ue_context.DRB_configList == NULL){ + ue_context_p->ue_context.DRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.DRB_configList)); + } + DRB_configList = ue_context_p->ue_context.DRB_configList; + for (int i=0; idrbs_to_be_setup_length; i++){ + DRB_config = CALLOC(1, sizeof(*DRB_config)); + DRB_config->drb_Identity = req->drbs_to_be_setup[i].drb_id; + ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config); + f1ap_drb_to_be_setup_t drb_p = req->drbs_to_be_setup[i]; + transport_layer_addr_t addr; + memcpy(addr.buffer, &drb_p.up_ul_tnl[0].tl_address, sizeof(drb_p.up_ul_tnl[0].tl_address)); + addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; + extern instance_t DUuniqInstance; + incoming_teid=newGtpuCreateTunnel(DUuniqInstance, + req->rnti, + drb_p.drb_id, + drb_p.drb_id, + drb_p.up_ul_tnl[0].teid, + addr, + 2152, + DURecvCb); + } + } + + if(req->srbs_to_be_setup_length>0 || req->drbs_to_be_setup_length>0){ + cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, + req->srbs_to_be_setup_length>0 ? 1:0, + req->drbs_to_be_setup_length>0 ? 1:0); + nr_rrc_rlc_config_asn1_req(&ctxt, + ue_context_p->ue_context.SRB_configList, + ue_context_p->ue_context.DRB_configList, + NULL, + NULL, + get_softmodem_params()->sa ? ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); + } + if(req->ReconfigComplOutcome == RRCreconf_failure){ + LOG_W(NR_RRC, "CU reporting RRC Reconfiguration failure \n"); + } + else if(req->ReconfigComplOutcome == RRCreconf_success){ + LOG_I(NR_RRC, "CU reporting RRC Reconfiguration success \n"); + } + + /* Fill the UE context setup response ITTI message to send to F1AP */ + resp->gNB_CU_ue_id = req->gNB_CU_ue_id; + resp->rnti = ctxt.rnti; + if(DRB_configList){ + if(DRB_configList->list.count > 0){ + resp->drbs_to_be_setup = calloc(1,DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t)); + resp->drbs_to_be_setup_length = DRB_configList->list.count; + for (int i=0; ilist.count; i++){ + resp->drbs_to_be_setup[i].drb_id = DRB_configList->list.array[i]->drb_Identity; + resp->drbs_to_be_setup[i].rlc_mode = RLC_MODE_AM; + resp->drbs_to_be_setup[i].up_dl_tnl[0].teid = incoming_teid; + resp->drbs_to_be_setup[i].up_dl_tnl[0].tl_address = inet_addr(mac->eth_params_n.my_addr); + resp->drbs_to_be_setup[i].up_dl_tnl_length = 1; + } + } + else{ + LOG_W(NR_RRC, "No DRB added upon reception of F1 UE context modification request with a DRB to setup list\n"); + } + } + if(SRB_configList){ + if(SRB_configList->list.count >0 && SRBs_before_new_addition < SRB_configList->list.count){ + resp->srbs_to_be_setup = calloc(1,req->srbs_to_be_setup_length*sizeof(f1ap_srb_to_be_setup_t)); + resp->srbs_to_be_setup_length = req->srbs_to_be_setup_length; + for (int i=SRBs_before_new_addition; ilist.count; i++){ + resp->srbs_to_be_setup[i-SRBs_before_new_addition].srb_id = SRB_configList->list.array[i]->srb_Identity; + } + } + else{ + LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context modification request at the DU\n"); + } + } + else{ + LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context modification request at the DU\n"); + } + + if(cellGroupConfig != NULL) { + resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, + NULL, + (void *)cellGroupConfig, + resp->du_to_cu_rrc_information, + 1024); + resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; + } + itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); +} + static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const char *msg_name, instance_t instance){ f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(msg_p); @@ -3967,21 +4096,21 @@ void *rrc_gnb_task(void *args_p) { rrc_gNB_process_f1_setup_req(&F1AP_SETUP_REQ(msg_p)); break; - case NR_DU_RRC_DL_INDICATION: - rrc_process_DU_DL(msg_p, msg_name_p, instance); - break; + case NR_DU_RRC_DL_INDICATION: + rrc_process_DU_DL(msg_p, msg_name_p, instance); + break; - case F1AP_UE_CONTEXT_SETUP_REQ: - rrc_DU_process_ue_context_setup_request(msg_p, msg_name_p, instance); - break; + case F1AP_UE_CONTEXT_SETUP_REQ: + rrc_DU_process_ue_context_setup_request(msg_p, msg_name_p, instance); + break; - case F1AP_UE_CONTEXT_SETUP_RESP: - rrc_CU_process_ue_context_setup_response(msg_p, msg_name_p, instance); - break; + case F1AP_UE_CONTEXT_SETUP_RESP: + rrc_CU_process_ue_context_setup_response(msg_p, msg_name_p, instance); + break; - case F1AP_UE_CONTEXT_MODIFICATION_REQ: - LOG_I(NR_RRC, "F1AP_UE_CONTEXT_MODIFICATION_REQ itti message received from the F1AP layer of the DU \n"); - break; + case F1AP_UE_CONTEXT_MODIFICATION_REQ: + rrc_DU_process_ue_context_modification_request(msg_p, msg_name_p, instance); + break; /* Messages from X2AP */ case X2AP_ENDC_SGNB_ADDITION_REQ: From a1b2d222ddc068c4af110fec06089a8823f58c45 Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 8 Oct 2021 10:31:53 +0200 Subject: [PATCH 06/84] Generation of UE context modification response at F1AP layer of the DU -Fix some indentations --- openair2/F1AP/f1ap_decoder.c | 4 + openair2/F1AP/f1ap_du_task.c | 2 +- openair2/F1AP/f1ap_du_ue_context_management.c | 357 ++++++++++-------- openair2/F1AP/f1ap_du_ue_context_management.h | 2 +- 4 files changed, 209 insertions(+), 156 deletions(-) diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index f1e4410786..60b3f94310 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -127,6 +127,10 @@ static int f1ap_decode_successful_outcome(F1AP_F1AP_PDU_t *pdu) { LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextSetup\n", __func__); break; + case F1AP_ProcedureCode_id_UEContextModification: + LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextModification\n", __func__); + break; + default: LOG_E(F1AP,"Unknown procedure ID (%d) for successfull outcome message\n", (int)pdu->choice.successfulOutcome->procedureCode); diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 915858d7da..1609fda459 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -211,7 +211,7 @@ void *F1AP_DU_task(void *arg) { case F1AP_UE_CONTEXT_MODIFICATION_RESP: LOG_I(F1AP, "DU task received itti message from RRC for F1AP_UE_CONTEXT_MODIFICATION_RESP message generation \n"); - //DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(myInstance, &F1AP_UE_CONTEXT_MODIFICATION_RESP(msg)); + DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(myInstance, &F1AP_UE_CONTEXT_MODIFICATION_RESP(msg)); break; case F1AP_UE_CONTEXT_RELEASE_REQ: // from MAC diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index cbbe563285..5f904330ad 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -253,7 +253,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, return 0; } -int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *req) { +int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *resp) { F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextSetupResponse_t *out; uint8_t *buffer=NULL; @@ -272,42 +272,40 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ie1->criticality = F1AP_Criticality_reject; ie1->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie1->value.choice.GNB_CU_UE_F1AP_ID = req->gNB_CU_ue_id; + ie1->value.choice.GNB_CU_UE_F1AP_ID = resp->gNB_CU_ue_id; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie2); ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie2->criticality = F1AP_Criticality_reject; ie2->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, req->rnti); + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, resp->rnti); /* mandatory */ /* c3. DUtoCURRCInformation */ - //if (0) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3); - ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; - ie3->criticality = F1AP_Criticality_reject; - ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; - { - /* cellGroupConfig */ - OCTET_STRING_fromBuf(&ie3->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)req->du_to_cu_rrc_information, - req->du_to_cu_rrc_information_length); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; + { + /* cellGroupConfig */ + OCTET_STRING_fromBuf(&ie3->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information, + resp->du_to_cu_rrc_information_length); - /* OPTIONAL */ - /* measGapConfig */ - if (0) { - asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.measGapConfig, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); - } - - /* OPTIONAL */ - /* requestedP_MaxFR1 */ - if (0) { - asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); - } + /* OPTIONAL */ + /* measGapConfig */ + if (0) { + asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.measGapConfig, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); } - //} + + /* OPTIONAL */ + /* requestedP_MaxFR1 */ + if (0) { + asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); + } + } /* optional */ /* c4. C_RNTI */ @@ -317,7 +315,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup ie4->criticality = F1AP_Criticality_ignore; ie4->value.present = F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI; //C_RNTI_TO_BIT_STRING(rntiP, &ie->value.choice.C_RNTI); - ie4->value.choice.C_RNTI=req->rnti; + ie4->value.choice.C_RNTI=resp->rnti; LOG_E(F1AP,"RNTI to code!\n"); } @@ -344,95 +342,95 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* mandatory */ /* c7. DRBs_Setup_List */ - if(req->drbs_to_be_setup_length > 0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie7); - ie7->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List; - ie7->criticality = F1AP_Criticality_ignore; - ie7->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List; - for (int i=0; i< req->drbs_to_be_setup_length; i++) { - // - asn1cSequenceAdd(ie7->value.choice.DRBs_Setup_List.list, - F1AP_DRBs_Setup_ItemIEs_t, drbs_setup_item_ies); - drbs_setup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_Item; - drbs_setup_item_ies->criticality = F1AP_Criticality_ignore; - drbs_setup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; - /* 7.1 DRBs_Setup_Item */ - /* ADD */ - F1AP_DRBs_Setup_Item_t *drbs_setup_item=&drbs_setup_item_ies->value.choice.DRBs_Setup_Item; - /* dRBID */ - drbs_setup_item->dRBID = req->drbs_to_be_setup[i].drb_id; - - /* OPTIONAL */ - /* lCID */ - //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); - //drbs_setup_item.lCID = 1L; - - for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { + if(resp->drbs_to_be_setup_length > 0){ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List; + ie7->criticality = F1AP_Criticality_ignore; + ie7->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List; + for (int i=0; i< resp->drbs_to_be_setup_length; i++) { + // + asn1cSequenceAdd(ie7->value.choice.DRBs_Setup_List.list, + F1AP_DRBs_Setup_ItemIEs_t, drbs_setup_item_ies); + drbs_setup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_Item; + drbs_setup_item_ies->criticality = F1AP_Criticality_ignore; + drbs_setup_item_ies->value.present = F1AP_DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item; + /* 7.1 DRBs_Setup_Item */ /* ADD */ - asn1cSequenceAdd(drbs_setup_item->dLUPTNLInformation_ToBeSetup_List.list, + F1AP_DRBs_Setup_Item_t *drbs_setup_item=&drbs_setup_item_ies->value.choice.DRBs_Setup_Item; + /* dRBID */ + drbs_setup_item->dRBID = resp->drbs_to_be_setup[i].drb_id; + + /* OPTIONAL */ + /* lCID */ + //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); + //drbs_setup_item.lCID = 1L; + + for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { + /* ADD */ + asn1cSequenceAdd(drbs_setup_item->dLUPTNLInformation_ToBeSetup_List.list, F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - /* gTPTunnel */ - asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); - /* transportLayerAddress */ - struct sockaddr_in addr= {0}; - inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, - &addr.sin_addr.s_addr); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, - &gTPTunnel->transportLayerAddress); - /* gTP_TEID */ - INT32_TO_OCTET_STRING(req->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); - } // for j - } // for i + dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + /* gTPTunnel */ + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); + /* transportLayerAddress */ + struct sockaddr_in addr= {0}; + inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, + &addr.sin_addr.s_addr); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, + &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + INT32_TO_OCTET_STRING(resp->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); + } // for j + } // for i + } /* mandatory */ /* c8. SRBs_FailedToBeSetup_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie8); - ie8->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List; - ie8->criticality = F1AP_Criticality_ignore; - ie8->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_FailedToBeSetup_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List; + ie8->criticality = F1AP_Criticality_ignore; + ie8->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_FailedToBeSetup_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie8->value.choice.SRBs_FailedToBeSetup_List.list, - F1AP_SRBs_FailedToBeSetup_ItemIEs_t, srbs_failedToBeSetup_item_ies); - srbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_Item; - srbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; - srbs_failedToBeSetup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; - /* 8.1 SRBs_Setup_Item */ - F1AP_SRBs_FailedToBeSetup_Item_t *srbs_failedToBeSetup_item= - &srbs_failedToBeSetup_item_ies->value.choice.SRBs_FailedToBeSetup_Item; - /* sRBID */ - srbs_failedToBeSetup_item->sRBID = 13L; - /* cause */ - asn1cCalloc(srbs_failedToBeSetup_item->cause, tmp); - // dummy value - tmp->present = F1AP_Cause_PR_radioNetwork; + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie8->value.choice.SRBs_FailedToBeSetup_List.list, + F1AP_SRBs_FailedToBeSetup_ItemIEs_t, srbs_failedToBeSetup_item_ies); + srbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_Item; + srbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; + srbs_failedToBeSetup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; + /* 8.1 SRBs_Setup_Item */ + F1AP_SRBs_FailedToBeSetup_Item_t *srbs_failedToBeSetup_item= + &srbs_failedToBeSetup_item_ies->value.choice.SRBs_FailedToBeSetup_Item; + /* sRBID */ + srbs_failedToBeSetup_item->sRBID = 13L; + /* cause */ + asn1cCalloc(srbs_failedToBeSetup_item->cause, tmp); + // dummy value + tmp->present = F1AP_Cause_PR_radioNetwork; - switch(tmp->present) { - case F1AP_Cause_PR_radioNetwork: - tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; - break; + switch(tmp->present) { + case F1AP_Cause_PR_radioNetwork: + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; + break; + case F1AP_Cause_PR_transport: + tmp->choice.transport = F1AP_CauseTransport_unspecified; + break; - case F1AP_Cause_PR_transport: - tmp->choice.transport = F1AP_CauseTransport_unspecified; - break; + case F1AP_Cause_PR_protocol: + tmp->choice.protocol = F1AP_CauseProtocol_unspecified; + break; - case F1AP_Cause_PR_protocol: - tmp->choice.protocol = F1AP_CauseProtocol_unspecified; - break; + case F1AP_Cause_PR_misc: + tmp->choice.misc = F1AP_CauseMisc_unspecified; + break; - case F1AP_Cause_PR_misc: - tmp->choice.misc = F1AP_CauseMisc_unspecified; - break; - - case F1AP_Cause_PR_NOTHING: - default: - break; - } // switch - } // for i + case F1AP_Cause_PR_NOTHING: + default: + break; + } // switch + } // for i } /* */ @@ -534,13 +532,13 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* mandatory */ /* c11. SRBs_Setup_List */ - if(req->srbs_to_be_setup_length > 0){ + if(resp->srbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie11); ie11->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_List; ie11->criticality = F1AP_Criticality_ignore; ie11->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_Setup_List; - for (int i=0; i< req->srbs_to_be_setup_length; i++) {// + for (int i=0; i< resp->srbs_to_be_setup_length; i++) {// asn1cSequenceAdd(ie11->value.choice.SRBs_Setup_List.list, F1AP_SRBs_Setup_ItemIEs_t, srbs_setup_item_ies); srbs_setup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_Item; @@ -550,7 +548,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* ADD */ F1AP_SRBs_Setup_Item_t *srbs_setup_item=&srbs_setup_item_ies->value.choice.SRBs_Setup_Item; /* sRBID */ - srbs_setup_item->sRBID = req->srbs_to_be_setup[i].srb_id; + srbs_setup_item->sRBID = resp->srbs_to_be_setup[i].srb_id; } } @@ -925,8 +923,8 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, /* mandatory */ /* GNB_DU_UE_F1AP_ID */ - F1AP_UEContextSetupRequestIEs_t *ieDU_UE; - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDU_UE, container, + F1AP_UEContextModificationRequestIEs_t *ieDU_UE; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieDU_UE, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); f1ap_ue_context_modification_req->gNB_DU_ue_id = ieDU_UE->value.choice.GNB_DU_UE_F1AP_ID; f1ap_ue_context_modification_req->rnti = f1ap_get_rnti_by_du_id(DUtype, instance, f1ap_ue_context_modification_req->gNB_DU_ue_id); @@ -959,7 +957,7 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, /* DRB */ F1AP_UEContextModificationRequestIEs_t *ieDrb; F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationRequestIEs_t, ieDrb, container, - F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, false); + F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List, false); if(ieDrb!=NULL) { f1ap_ue_context_modification_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetupMod_List.list.count; @@ -1059,7 +1057,7 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, } //void DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(F1AP_UEContextModificationResponse_t *UEContextModificationResponse) { -int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { +int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *resp) { F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextModificationResponse_t *out; uint8_t *buffer=NULL; @@ -1078,14 +1076,14 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ie1->criticality = F1AP_Criticality_reject; ie1->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie1->value.choice.GNB_CU_UE_F1AP_ID = 126L; + ie1->value.choice.GNB_CU_UE_F1AP_ID = resp->gNB_CU_ue_id; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie2); ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie2->criticality = F1AP_Criticality_reject; ie2->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie2->value.choice.GNB_DU_UE_F1AP_ID = 651L; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, resp->rnti); /* optional */ /* c3. ResourceCoordinationTransferContainer */ @@ -1098,61 +1096,80 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { strlen("asdsa1d32sa1d31asd31as")); } - /* optional */ - /* c4. DUtoCURRCInformation */ - if (0) { + /* mandatory */ + /* c3. DUtoCURRCInformation */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie4); ie4->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; ie4->criticality = F1AP_Criticality_reject; ie4->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation; - OCTET_STRING_fromBuf(&ie4->value.choice.DUtoCURRCInformation.cellGroupConfig, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + { + /* cellGroupConfig */ + OCTET_STRING_fromBuf(&ie4->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information, + resp->du_to_cu_rrc_information_length); - /* OPTIONAL */ - if (1) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie41); - ie41->value.choice.DUtoCURRCInformation.measGapConfig = (F1AP_MeasGapConfig_t *)calloc(1, sizeof(F1AP_MeasGapConfig_t)); - OCTET_STRING_fromBuf( ie41->value.choice.DUtoCURRCInformation.measGapConfig, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + /* OPTIONAL */ + /* measGapConfig */ + if (0) { + asn1cCalloc(ie4->value.choice.DUtoCURRCInformation.measGapConfig, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); + } + + /* OPTIONAL */ + /* requestedP_MaxFR1 */ + if (0) { + asn1cCalloc(ie4->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); + } } - } - /* mandatory */ - /* c5. DRBs_SetupMod_List */ + + /* optional */ + /* c5. DRBs_Setup_List */ + if(resp->drbs_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie5); ie5->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List; - ie5->criticality = F1AP_Criticality_reject; + ie5->criticality = F1AP_Criticality_ignore; ie5->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List; - - for (int i=0; i<1; i++) { + for (int i=0; i< resp->drbs_to_be_setup_length; i++) { // asn1cSequenceAdd(ie5->value.choice.DRBs_SetupMod_List.list, - F1AP_DRBs_SetupMod_ItemIEs_t, drbs_setupMod_item_ies); - drbs_setupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_Item; - drbs_setupMod_item_ies->criticality = F1AP_Criticality_reject; - drbs_setupMod_item_ies->value.present = F1AP_DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item; - /* 10.1 DRBs_SetupMod_Item */ - F1AP_DRBs_SetupMod_Item_t *drbs_setupMod_item=&drbs_setupMod_item_ies->value.choice.DRBs_SetupMod_Item; + F1AP_DRBs_SetupMod_ItemIEs_t, drbs_setupmod_item_ies); + drbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_Item; + drbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; + drbs_setupmod_item_ies->value.present = F1AP_DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item; + /* 7.1 DRBs_Setup_Item */ + /* ADD */ + F1AP_DRBs_SetupMod_Item_t *drbs_setupmod_item=&drbs_setupmod_item_ies->value.choice.DRBs_SetupMod_Item; /* dRBID */ - drbs_setupMod_item->dRBID = 30L; - /* DLTunnels_SetupMod_List */ - int maxnoofDLUPTNLInformation = 1; // 2; + drbs_setupmod_item->dRBID = resp->drbs_to_be_setup[i].drb_id; - for (int j=0; jvalue.choice.DRBs_SetupMod_List.list, + /* OPTIONAL */ + /* lCID */ + //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); + //drbs_setup_item.lCID = 1L; + + for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { + /* ADD */ + asn1cSequenceAdd(drbs_setupmod_item->dLUPTNLInformation_ToBeSetup_List.list, F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, - gTPTunnel); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", - strlen("1204")); - } + /* gTPTunnel */ + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); + /* transportLayerAddress */ + struct sockaddr_in addr= {0}; + inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, + &addr.sin_addr.s_addr); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, + &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + INT32_TO_OCTET_STRING(resp->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); + } // for j + } // for i } - /* mandatory */ + /* optional */ /* c6. DRBs_Modified_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie6); ie6->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; ie6->criticality = F1AP_Criticality_reject; @@ -1184,9 +1201,11 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); } } + } - /* mandatory */ + /* optional */ /* c7. SRBs_FailedToBeSetupMod_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie7); ie7->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; ie7->criticality = F1AP_Criticality_reject; @@ -1208,9 +1227,11 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { tmp->present = F1AP_Cause_PR_radioNetwork; tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } + } - /* mandatory */ + /* optional */ /* c8. DRBs_FailedToBeSetupMod_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie8); ie8->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; ie8->criticality = F1AP_Criticality_reject; @@ -1232,9 +1253,11 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { drbs_failedToBeSetupMod_item->cause->present = F1AP_Cause_PR_radioNetwork; drbs_failedToBeSetupMod_item->cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } + } - /* mandatory */ + /* optional */ /* c9. SCell_FailedtoSetupMod_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie9); ie9->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List; ie9->criticality = F1AP_Criticality_ignore; @@ -1255,9 +1278,11 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { tmp->present = F1AP_Cause_PR_radioNetwork; tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } + } - /* mandatory */ + /* optional */ /* c10. DRBs_FailedToBeModified_List */ + if(0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie10); ie10->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_List; ie10->criticality = F1AP_Criticality_reject; @@ -1279,6 +1304,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { tmp->present = F1AP_Cause_PR_radioNetwork; tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } + } // /* */ /* c11. CriticalityDiagnostics */ @@ -1328,6 +1354,28 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { } } } + /* optional */ + /* c12. SRBs_Setup_List */ + if(resp->srbs_to_be_setup_length > 0){ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_List; + ie12->criticality = F1AP_Criticality_ignore; + ie12->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_SetupMod_List; + + for (int i=0; i< resp->srbs_to_be_setup_length; i++) {// + asn1cSequenceAdd(ie12->value.choice.SRBs_SetupMod_List.list, + F1AP_SRBs_SetupMod_ItemIEs_t, srbs_setupmod_item_ies); + srbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_Item; + srbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; + srbs_setupmod_item_ies->value.present = F1AP_SRBs_SetupMod_ItemIEs__value_PR_SRBs_SetupMod_Item; + /* 11.1 SRBs_Setup_Item */ + /* ADD */ + F1AP_SRBs_SetupMod_Item_t *srbs_setupmod_item=&srbs_setupmod_item_ies->value.choice.SRBs_SetupMod_Item; + /* sRBID */ + srbs_setupmod_item->sRBID = resp->srbs_to_be_setup[i].srb_id; + srbs_setupmod_item->lCID = resp->srbs_to_be_setup[i].srb_id; + } + } /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -1335,9 +1383,10 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { return -1; } - //f1ap_itti_send_sctp_data_req(false, instance, buffer, len, 0); + f1ap_itti_send_sctp_data_req(false, instance, buffer, len, getCxt(false, instance)->default_sctp_stream_id); return 0; } + int DU_send_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance) { AssertFatal(1==0,"Not implemented yet\n"); } diff --git a/openair2/F1AP/f1ap_du_ue_context_management.h b/openair2/F1AP/f1ap_du_ue_context_management.h index 82643fa933..acf74f69d7 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.h +++ b/openair2/F1AP/f1ap_du_ue_context_management.h @@ -74,7 +74,7 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu); -int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance); +int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *resp); int DU_send_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance); From d3899a21a6bfbeb538a92bb66c047b03147e15a7 Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 8 Oct 2021 13:37:46 +0200 Subject: [PATCH 07/84] Add implementation of UE context modification response handler at F1AP layer of the CU --- openair2/F1AP/f1ap_cu_ue_context_management.c | 126 +++++++++++++++++- openair2/F1AP/f1ap_handlers.c | 2 +- openair2/RRC/NR/rrc_gNB.c | 8 ++ 3 files changed, 134 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 087d63d3f1..02cfb80ac7 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1646,7 +1646,131 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - AssertFatal(1==0,"Not implemented yet\n"); + + MessageDef *msg_p; + F1AP_UEContextModificationResponse_t *container; + F1AP_UEContextModificationResponseIEs_t *ie; + DevAssert(pdu); + msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_MODIFICATION_RESP); + f1ap_ue_context_setup_t *f1ap_ue_context_modification_resp = &F1AP_UE_CONTEXT_MODIFICATION_RESP(msg_p); + container = &pdu->choice.successfulOutcome->value.choice.UEContextModificationResponse; + int i; + + /* GNB_CU_UE_F1AP_ID */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, false); + f1ap_ue_context_modification_resp->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID; + + LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_CU_ue_id is: %d \n", f1ap_ue_context_modification_resp->gNB_CU_ue_id); + + /* GNB_DU_UE_F1AP_ID */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); + f1ap_ue_context_modification_resp->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID; + + LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_DU_ue_id is: %d \n", f1ap_ue_context_modification_resp->gNB_DU_ue_id); + + f1ap_ue_context_modification_resp->rnti = + f1ap_get_rnti_by_du_id(CUtype, instance, f1ap_ue_context_modification_resp->gNB_DU_ue_id); + + // DUtoCURRCInformation + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, true); + if (ie == NULL){ + LOG_E(F1AP,"%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } + f1ap_ue_context_modification_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + + memcpy(f1ap_ue_context_modification_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_modification_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + + // DRBs_SetupMod_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List, false); + if(ie!=NULL){ + f1ap_ue_context_modification_resp->drbs_to_be_setup_length = ie->value.choice.DRBs_SetupMod_List.list.count; + f1ap_ue_context_modification_resp->drbs_to_be_setup = calloc(f1ap_ue_context_modification_resp->drbs_to_be_setup_length, + sizeof(f1ap_drb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_resp->drbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_setup\n"); + for (i = 0; i < f1ap_ue_context_modification_resp->drbs_to_be_setup_length; ++i) { + f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_modification_resp->drbs_to_be_setup[i]; + F1AP_DRBs_SetupMod_Item_t *drbs_setupmod_item_p; + drbs_setupmod_item_p = &((F1AP_DRBs_SetupMod_ItemIEs_t *)ie->value.choice.DRBs_SetupMod_List.list.array[i])->value.choice.DRBs_SetupMod_Item; + drb_p->drb_id = drbs_setupmod_item_p->dRBID; + // TODO in the following, assume only one UP UL TNL is present. + // this matches/assumes OAI CU/DU implementation, can be up to 2! + drb_p->up_dl_tnl_length = 1; + AssertFatal(drbs_setupmod_item_p->dLUPTNLInformation_ToBeSetup_List.list.count > 0, + "no DL UP TNL Information in DRBs to be Setup list\n"); + F1AP_DLUPTNLInformation_ToBeSetup_Item_t *dl_up_tnl_info_p = (F1AP_DLUPTNLInformation_ToBeSetup_Item_t *)drbs_setupmod_item_p->dLUPTNLInformation_ToBeSetup_List.list.array[0]; + F1AP_GTPTunnel_t *dl_up_tnl0 = dl_up_tnl_info_p->dLUPTNLInformation.choice.gTPTunnel; + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&dl_up_tnl0->transportLayerAddress, drb_p->up_dl_tnl[0].tl_address); + OCTET_STRING_TO_INT32(&dl_up_tnl0->gTP_TEID, drb_p->up_dl_tnl[0].teid); + GtpuUpdateTunnelOutgoingTeid(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_modification_resp->rnti, + (ebi_t)drbs_setupmod_item_p->dRBID, + drb_p->up_dl_tnl[0].teid); + } + } + // SRBs_FailedToBeSetupMod_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List, false); + if(ie!=NULL){ + f1ap_ue_context_modification_resp->srbs_failed_to_be_setup_length = ie->value.choice.SRBs_FailedToBeSetupMod_List.list.count; + f1ap_ue_context_modification_resp->srbs_failed_to_be_setup = calloc(f1ap_ue_context_modification_resp->srbs_failed_to_be_setup_length, + sizeof(f1ap_rb_failed_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_resp->srbs_failed_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->srbs_failed_to_be_setup\n"); + for (i = 0; i < f1ap_ue_context_modification_resp->srbs_failed_to_be_setup_length; ++i) { + f1ap_rb_failed_to_be_setup_t *srb_p = &f1ap_ue_context_modification_resp->srbs_failed_to_be_setup[i]; + srb_p->rb_id = ((F1AP_SRBs_FailedToBeSetupMod_Item_t *)ie->value.choice.SRBs_FailedToBeSetupMod_List.list.array[i])->sRBID; + } + + } + // DRBs_FailedToBeSetupMod_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List, false); + if(ie!=NULL){ + f1ap_ue_context_modification_resp->drbs_failed_to_be_setup_length = ie->value.choice.DRBs_FailedToBeSetupMod_List.list.count; + f1ap_ue_context_modification_resp->drbs_failed_to_be_setup = calloc(f1ap_ue_context_modification_resp->drbs_failed_to_be_setup_length, + sizeof(f1ap_rb_failed_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_resp->drbs_failed_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_failed_to_be_setup\n"); + for (i = 0; i < f1ap_ue_context_modification_resp->drbs_failed_to_be_setup_length; ++i) { + f1ap_rb_failed_to_be_setup_t *drb_p = &f1ap_ue_context_modification_resp->drbs_failed_to_be_setup[i]; + drb_p->rb_id = ((F1AP_DRBs_FailedToBeSetupMod_Item_t *)ie->value.choice.DRBs_FailedToBeSetupMod_List.list.array[i])->dRBID; + } + } + + // SCell_FailedtoSetupMod_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List, false); + if(ie!=NULL){ + LOG_E (F1AP, "Not supporting handling of SCell_FailedtoSetupMod_List \n"); + } + + // SRBs_Setup_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_SRBs_SetupMod_List, false); + if(ie!=NULL){ + f1ap_ue_context_modification_resp->srbs_to_be_setup_length = ie->value.choice.SRBs_SetupMod_List.list.count; + f1ap_ue_context_modification_resp->srbs_to_be_setup = calloc(f1ap_ue_context_modification_resp->srbs_to_be_setup_length, + sizeof(f1ap_srb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_modification_resp->srbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_setup\n"); + for (i = 0; i < f1ap_ue_context_modification_resp->srbs_to_be_setup_length; ++i) { + f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_modification_resp->srbs_to_be_setup[i]; + F1AP_SRBs_SetupMod_Item_t *srbs_setup_item_p; + srbs_setup_item_p = &((F1AP_SRBs_SetupMod_ItemIEs_t *)ie->value.choice.SRBs_SetupMod_List.list.array[i])->value.choice.SRBs_SetupMod_Item; + srb_p->srb_id = srbs_setup_item_p->sRBID; + srb_p->lcid = srbs_setup_item_p->lCID; + } + } + + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); + return 0; } int CU_handle_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance, diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index 6bbf1c796d..0812a976f6 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -50,7 +50,7 @@ f1ap_message_processing_t f1ap_messages_processing[][3] = { { DU_handle_gNB_CU_CONFIGURATION_UPDATE, CU_handle_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE, CU_handle_gNB_CU_CONFIGURATION_UPDATE_FAILURE }, /* gNBCUConfigurationUpdate */ { DU_handle_UE_CONTEXT_SETUP_REQUEST, CU_handle_UE_CONTEXT_SETUP_RESPONSE, 0 }, /* UEContextSetup */ { DU_handle_UE_CONTEXT_RELEASE_COMMAND, CU_handle_UE_CONTEXT_RELEASE_COMPLETE, 0 }, /* UEContextRelease */ - { DU_handle_UE_CONTEXT_MODIFICATION_REQUEST, 0, 0 }, /* UEContextModification */ + { DU_handle_UE_CONTEXT_MODIFICATION_REQUEST, CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE, 0 }, /* UEContextModification */ { 0, 0, 0 }, /* UEContextModificationRequired */ { 0, 0, 0 }, /* UEMobilityCommand */ { CU_handle_UE_CONTEXT_RELEASE_REQUEST, 0, 0 }, /* UEContextReleaseRequest */ diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 92c6fe62d4..30f4ba6f6a 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3606,6 +3606,10 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch } +static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, const char *msg_name, instance_t instance){ + LOG_I(NR_RRC, "RRC processing of F1 ue_context modification response at the CU is pending \n"); +} + unsigned int mask_flip(unsigned int x) { return((((x>>8) + (x<<8))&0xffff)>>6); } @@ -4108,6 +4112,10 @@ void *rrc_gnb_task(void *args_p) { rrc_CU_process_ue_context_setup_response(msg_p, msg_name_p, instance); break; + case F1AP_UE_CONTEXT_MODIFICATION_RESP: + rrc_CU_process_ue_context_modification_response(msg_p, msg_name_p, instance); + break; + case F1AP_UE_CONTEXT_MODIFICATION_REQ: rrc_DU_process_ue_context_modification_request(msg_p, msg_name_p, instance); break; From e2c88f91afcd8e76a71b6122e9eae12097c3355f Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 8 Oct 2021 18:29:39 +0200 Subject: [PATCH 08/84] Trigger dedicated RRC Reconfiguration after processing F1 UE context modification response at RRC layer of the CU -Successful user-plane traffic over F1-U upon completion of UE context modification procedures --- openair2/F1AP/f1ap_cu_ue_context_management.c | 14 +++-- openair2/RRC/NR/rrc_gNB.c | 54 ++++++++++++++++--- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 02cfb80ac7..085367e64f 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1675,15 +1675,13 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, // DUtoCURRCInformation F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, true); - if (ie == NULL){ - LOG_E(F1AP,"%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); - return -1; - } - f1ap_ue_context_modification_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, false); + if(ie!=NULL){ + f1ap_ue_context_modification_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - memcpy(f1ap_ue_context_modification_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - f1ap_ue_context_modification_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + memcpy(f1ap_ue_context_modification_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_modification_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + } // DRBs_SetupMod_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 30f4ba6f6a..30dd2e11d2 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3494,12 +3494,7 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, req->srbs_to_be_setup_length>0 ? 1:0, req->drbs_to_be_setup_length>0 ? 1:0); - nr_rrc_rlc_config_asn1_req(&ctxt, - ue_context_p->ue_context.SRB_configList, - ue_context_p->ue_context.DRB_configList, - NULL, - NULL, - get_softmodem_params()->sa ? ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); + apply_macrlc_config(rrc, ue_context_p, &ctxt); } if(req->ReconfigComplOutcome == RRCreconf_failure){ LOG_W(NR_RRC, "CU reporting RRC Reconfiguration failure \n"); @@ -3607,7 +3602,52 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch } static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, const char *msg_name, instance_t instance){ - LOG_I(NR_RRC, "RRC processing of F1 ue_context modification response at the CU is pending \n"); + + f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(msg_p); + protocol_ctxt_t ctxt; + ctxt.rnti = resp->rnti; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + ctxt.eNB_index = instance; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt.rnti); + NR_CellGroupConfig_t *cellGroupConfig = NULL; + + if(resp->du_to_cu_rrc_information!=NULL){ + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_CellGroupConfig, + (void **)&cellGroupConfig, + (uint8_t *)resp->du_to_cu_rrc_information, + (int) resp->du_to_cu_rrc_information_length); + + if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + AssertFatal(1==0,"Cell group config decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, cellGroupConfig, 1 ); + return; + } + //xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, cellGroupConfig); + + if(ue_context_p->ue_context.masterCellGroup == NULL){ + ue_context_p->ue_context.masterCellGroup = calloc(1, sizeof(NR_CellGroupConfig_t)); + } + if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ + if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ + LOG_I(NR_RRC, "rlc_BearerToAddModList not empty before filling it \n"); + free(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList); + } + ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, + sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + } + xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); + + rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, cellGroupConfig); + + free(cellGroupConfig->rlc_BearerToAddModList); + free(cellGroupConfig); + } } unsigned int mask_flip(unsigned int x) { From 1a40b36193fb9635a8109c5fb0ac98e96dc76d5b Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 12 Oct 2021 19:38:19 +0200 Subject: [PATCH 09/84] Use correct SCTP port number for F1AP according to standards --- openair2/F1AP/f1ap_default_values.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/F1AP/f1ap_default_values.h b/openair2/F1AP/f1ap_default_values.h index 91a1179624..7c64614f50 100644 --- a/openair2/F1AP/f1ap_default_values.h +++ b/openair2/F1AP/f1ap_default_values.h @@ -40,7 +40,7 @@ #define ENB_NAME "Eurecom ENB" #define ENB_NAME_FORMAT (ENB_NAME" %u") -#define F1AP_PORT_NUMBER (30923) +#define F1AP_PORT_NUMBER (38472) #define F1AP_SCTP_PPID (62) #endif /* F1AP_DEFAULT_VALUES_H_ */ From b37195ad1fc66d30f4e140c7ddc3ad9bf37b35da Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 13 Oct 2021 14:36:38 +0200 Subject: [PATCH 10/84] Few updates on handling master cell group configuration updates coming from the DU --- openair2/RRC/NR/rrc_gNB.c | 40 ++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index c47131e3e4..2d5b9466f7 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1124,6 +1124,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup,1,1); } else{ + LOG_I(NR_RRC, "Master cell group originating from the DU \n"); cellGroupConfig = cell_groupConfig_from_DU; } size = do_RRCReconfiguration(ctxt_pP, buffer, @@ -3411,8 +3412,8 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context setup request at the DU\n"); } /* fixme: - * Here we should be probably be encoding to UE ctxt setup response the updates on cellgroupconfig (i.e., cellGroupConfig) - * instead of the whole masterCellGroup configuration stored at the UE context (i.e., ue_context_p->ue_context.masterCellGroup). + * Here we should be encoding the updates on cellgroupconfig. Currently the content of + * celGroupConfig is empty because update_cellGroupConfig() function that is previously called is empty. */ resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, @@ -3420,6 +3421,10 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha (void *)cellGroupConfig, resp->du_to_cu_rrc_information, 1024); + if (enc_rval.encoded == -1) { + LOG_E(F1AP,"Could not encode ue_context.masterCellGroup, failed element %s\n",enc_rval.failed_type->name); + exit(-1); + } resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; free(cellGroupConfig); itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); @@ -3582,12 +3587,18 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch } if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ - LOG_I(NR_RRC, "rlc_BearerToAddModList not empty before filling it \n"); - free(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList); + int ue_ctxt_rlc_Bearers = ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList->list.count; + for(int i=ue_ctxt_rlc_Bearers; irlc_BearerToAddModList->list.count; i++){ + ASN_SEQUENCE_ADD(&ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList->list, + cellGroupConfig->rlc_BearerToAddModList->list.array[i-ue_ctxt_rlc_Bearers]); + } } - ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, + else{ + LOG_W(NR_RRC, "Empty rlc_BearerToAddModList at ue_context of the CU before filling the updates from UE context setup response \n"); + ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + } } xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); @@ -3633,7 +3644,7 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, c if(ue_context_p->ue_context.masterCellGroup == NULL){ ue_context_p->ue_context.masterCellGroup = calloc(1, sizeof(NR_CellGroupConfig_t)); } - if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ + /*if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ LOG_I(NR_RRC, "rlc_BearerToAddModList not empty before filling it \n"); free(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList); @@ -3641,6 +3652,21 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, c ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + }*/ + if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ + if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ + int ue_ctxt_rlc_Bearers = ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList->list.count; + for(int i=ue_ctxt_rlc_Bearers; irlc_BearerToAddModList->list.count; i++){ + ASN_SEQUENCE_ADD(&ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList->list, + cellGroupConfig->rlc_BearerToAddModList->list.array[i-ue_ctxt_rlc_Bearers]); + } + } + else{ + LOG_W(NR_RRC, "Empty rlc_BearerToAddModList at ue_context of the CU before filling the updates from UE context setup response \n"); + ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, + sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + } } xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); From 40b131be13c5305cc31b517c3cc205c363a626ee Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 13 Oct 2021 16:45:42 +0200 Subject: [PATCH 11/84] Small corrections in F1AP UE context management messages and indentation fixes --- openair2/F1AP/f1ap_cu_ue_context_management.c | 60 ++-- openair2/F1AP/f1ap_du_ue_context_management.c | 331 +++++++++--------- openair2/RRC/NR/rrc_gNB.c | 1 + 3 files changed, 193 insertions(+), 199 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 065b0fd57e..2e2ee1e0ac 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1090,52 +1090,52 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context } /* optional */ - /* c5. CUtoDURRCInformation */ + /* c6. CUtoDURRCInformation */ if (f1ap_ue_context_modification_req->cu_to_du_rrc_information!=NULL) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie5); - ie5->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; - ie5->criticality = F1AP_Criticality_reject; - ie5->value.present = F1AP_UEContextModificationRequestIEs__value_PR_CUtoDURRCInformation; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; + ie6->criticality = F1AP_Criticality_reject; + ie6->value.present = F1AP_UEContextModificationRequestIEs__value_PR_CUtoDURRCInformation; /* 6.1 cG_ConfigInfo */ if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->cG_ConfigInfo!=NULL){ - const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; - asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.cG_ConfigInfo, cG_ConfigInfo); - OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen(cG_ConfigInfoStr)) ; + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.cG_ConfigInfo, cG_ConfigInfo); + OCTET_STRING_fromBuf(cG_ConfigInfo, (const char *)f1ap_ue_context_modification_req->cu_to_du_rrc_information->cG_ConfigInfo, + f1ap_ue_context_modification_req->cu_to_du_rrc_information->cG_ConfigInfo_length); } /* optional */ /* 6.2 uE_CapabilityRAT_ContainerList */ if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ - asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, (const char *)f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, f1ap_ue_context_modification_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length) ; } /* optional */ /* 6.3 measConfig */ if(f1ap_ue_context_modification_req->cu_to_du_rrc_information->measConfig!=NULL){ - const char measConfigStr[]="asdsa1d32sa1d31asd31as"; - asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.measConfig, measConfig); - OCTET_STRING_fromBuf(measConfig, measConfigStr, strlen(measConfigStr)) ; + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.measConfig, measConfig); + OCTET_STRING_fromBuf(measConfig, (const char *)f1ap_ue_context_modification_req->cu_to_du_rrc_information->measConfig, + f1ap_ue_context_modification_req->cu_to_du_rrc_information->measConfig_length); } } /* optional */ - /* c6. TransmissionActionIndicator */ + /* c7. TransmissionActionIndicator */ if (0) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie6); - ie6->id = F1AP_ProtocolIE_ID_id_TransmissionActionIndicator; - ie6->criticality = F1AP_Criticality_ignore; - ie6->value.present = F1AP_UEContextModificationRequestIEs__value_PR_TransmissionActionIndicator; - ie6->value.choice.TransmissionActionIndicator = F1AP_TransmissionActionIndicator_stop; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_TransmissionActionIndicator; + ie7->criticality = F1AP_Criticality_ignore; + ie7->value.present = F1AP_UEContextModificationRequestIEs__value_PR_TransmissionActionIndicator; + ie7->value.choice.TransmissionActionIndicator = F1AP_TransmissionActionIndicator_stop; } /* optional */ - /* c7. ResourceCoordinationTransferContainer */ + /* c8. ResourceCoordinationTransferContainer */ if (0) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie7); - ie7->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; - ie7->criticality = F1AP_Criticality_ignore; - ie7->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ResourceCoordinationTransferContainer; - OCTET_STRING_fromBuf(&ie7->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; + ie8->criticality = F1AP_Criticality_ignore; + ie8->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ResourceCoordinationTransferContainer; + OCTET_STRING_fromBuf(&ie8->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); } @@ -1152,11 +1152,11 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context /* optional */ /* c8. RRCContainer */ if (0) { - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie8); - ie8->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie8->criticality = F1AP_Criticality_ignore; - ie8->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie8->value.choice.RRCContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie81); + ie81->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie81->criticality = F1AP_Criticality_ignore; + ie81->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie81->value.choice.RRCContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); } @@ -1661,7 +1661,7 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, false); + F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); f1ap_ue_context_modification_resp->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID; LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_CU_ue_id is: %d \n", f1ap_ue_context_modification_resp->gNB_CU_ue_id); diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index e0ff41d71e..ce47fec196 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -970,20 +970,20 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, for (i = 0; i < f1ap_ue_context_modification_req->drbs_to_be_setup_length; ++i) { f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_modification_req->drbs_to_be_setup[i]; - F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p = - &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetupMod_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item; - drb_p->drb_id = drbs_tobesetup_item_p->dRBID; + F1AP_DRBs_ToBeSetupMod_Item_t *drbs_tobesetupmod_item_p = + &((F1AP_DRBs_ToBeSetupMod_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetupMod_List.list.array[i])->value.choice.DRBs_ToBeSetupMod_Item; + drb_p->drb_id = drbs_tobesetupmod_item_p->dRBID; /* TODO in the following, assume only one UP UL TNL is present. * this matches/assumes OAI CU implementation, can be up to 2! */ drb_p->up_ul_tnl_length = 1; - AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0, + AssertFatal(drbs_tobesetupmod_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0, "no UL UP TNL Information in DRBs to be Setup list\n"); - F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0]; + F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetupmod_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0]; F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel; BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address); OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid); - switch (drbs_tobesetup_item_p->rLCMode) { + switch (drbs_tobesetupmod_item_p->rLCMode) { case F1AP_RLCMode_rlc_am: drb_p->rlc_mode = RLC_MODE_AM; break; @@ -1042,8 +1042,9 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, //FIXME //rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); ctxt.instance = instance; - ctxt.instance = instance; + ctxt.module_id = instance; ctxt.enb_flag = 1; + ctxt.eNB_index = instance; mem_block_t *pdcp_pdu_p = get_free_mem_block(ieRRC->value.choice.RRCContainer.size, __func__); memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p); @@ -1099,7 +1100,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex } /* mandatory */ - /* c3. DUtoCURRCInformation */ + /* c4. DUtoCURRCInformation */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie4); ie4->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; ie4->criticality = F1AP_Criticality_reject; @@ -1127,185 +1128,177 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* optional */ /* c5. DRBs_Setup_List */ - if(resp->drbs_to_be_setup_length > 0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie5); - ie5->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List; - ie5->criticality = F1AP_Criticality_ignore; - ie5->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List; - for (int i=0; i< resp->drbs_to_be_setup_length; i++) { - // - asn1cSequenceAdd(ie5->value.choice.DRBs_SetupMod_List.list, - F1AP_DRBs_SetupMod_ItemIEs_t, drbs_setupmod_item_ies); - drbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_Item; - drbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; - drbs_setupmod_item_ies->value.present = F1AP_DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item; - /* 7.1 DRBs_Setup_Item */ - /* ADD */ - F1AP_DRBs_SetupMod_Item_t *drbs_setupmod_item=&drbs_setupmod_item_ies->value.choice.DRBs_SetupMod_Item; - /* dRBID */ - drbs_setupmod_item->dRBID = resp->drbs_to_be_setup[i].drb_id; - - /* OPTIONAL */ - /* lCID */ - //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); - //drbs_setup_item.lCID = 1L; - - for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { + if(resp->drbs_to_be_setup_length > 0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List; + ie5->criticality = F1AP_Criticality_ignore; + ie5->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List; + for (int i=0; i< resp->drbs_to_be_setup_length; i++) { + asn1cSequenceAdd(ie5->value.choice.DRBs_SetupMod_List.list, F1AP_DRBs_SetupMod_ItemIEs_t, drbs_setupmod_item_ies); + drbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_Item; + drbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; + drbs_setupmod_item_ies->value.present = F1AP_DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item; + /* 7.1 DRBs_Setup_Item */ /* ADD */ - asn1cSequenceAdd(drbs_setupmod_item->dLUPTNLInformation_ToBeSetup_List.list, - F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - /* gTPTunnel */ - asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); - /* transportLayerAddress */ - struct sockaddr_in addr= {0}; - inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, - &addr.sin_addr.s_addr); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, + F1AP_DRBs_SetupMod_Item_t *drbs_setupmod_item=&drbs_setupmod_item_ies->value.choice.DRBs_SetupMod_Item; + /* dRBID */ + drbs_setupmod_item->dRBID = resp->drbs_to_be_setup[i].drb_id; + + /* OPTIONAL */ + /* lCID */ + //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); + //drbs_setup_item.lCID = 1L; + + for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { + /* ADD */ + asn1cSequenceAdd(drbs_setupmod_item->dLUPTNLInformation_ToBeSetup_List.list, + F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); + dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + /* gTPTunnel */ + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); + /* transportLayerAddress */ + struct sockaddr_in addr= {0}; + inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, + &addr.sin_addr.s_addr); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, &gTPTunnel->transportLayerAddress); - /* gTP_TEID */ - INT32_TO_OCTET_STRING(resp->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); - } // for j - } // for i + /* gTP_TEID */ + INT32_TO_OCTET_STRING(resp->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); + } // for j + } // for i } /* optional */ /* c6. DRBs_Modified_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie6); - ie6->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; - ie6->criticality = F1AP_Criticality_reject; - ie6->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_Modified_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; + ie6->criticality = F1AP_Criticality_reject; + ie6->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_Modified_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie6->value.choice.DRBs_Modified_List.list, - F1AP_DRBs_Modified_ItemIEs_t, drbs_modified_item_ies); - drbs_modified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_Item; - drbs_modified_item_ies->criticality = F1AP_Criticality_reject; - drbs_modified_item_ies->value.present = F1AP_DRBs_Modified_ItemIEs__value_PR_DRBs_Modified_Item; - /* 13.1 SRBs_modified_Item */ - F1AP_DRBs_Modified_Item_t *drbs_modified_item= - &drbs_modified_item_ies->value.choice.DRBs_Modified_Item; - /* dRBID */ - drbs_modified_item->dRBID = 25L; - /* ULTunnels_Modified_List */ - int maxnoofULTunnels = 1; // 2; + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie6->value.choice.DRBs_Modified_List.list, + F1AP_DRBs_Modified_ItemIEs_t, drbs_modified_item_ies); + drbs_modified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_Item; + drbs_modified_item_ies->criticality = F1AP_Criticality_reject; + drbs_modified_item_ies->value.present = F1AP_DRBs_Modified_ItemIEs__value_PR_DRBs_Modified_Item; + /* DRBs_modified_Item */ + F1AP_DRBs_Modified_Item_t *drbs_modified_item= &drbs_modified_item_ies->value.choice.DRBs_Modified_Item; + /* dRBID */ + drbs_modified_item->dRBID = 25L; + /* ULTunnels_Modified_List */ + int maxnoofULTunnels = 1; // 2; - for (int j=0; jdLUPTNLInformation_ToBeSetup_List.list, - F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); - asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item, tmp); - tmp->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, gTPTunnel); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); + for (int j=0; jdLUPTNLInformation_ToBeSetup_List.list, + F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item, tmp); + tmp->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, gTPTunnel); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); + } } } - } /* optional */ /* c7. SRBs_FailedToBeSetupMod_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie7); - ie7->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; - ie7->criticality = F1AP_Criticality_reject; - ie7->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_FailedToBeSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; + ie7->criticality = F1AP_Criticality_reject; + ie7->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_FailedToBeSetupMod_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie7->value.choice.SRBs_FailedToBeSetupMod_List.list, - F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t, srbs_failedToBeSetupMod_item_ies); - srbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_Item; - srbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; - srbs_failedToBeSetupMod_item_ies->value.present = F1AP_SRBs_FailedToBeSetupMod_ItemIEs__value_PR_SRBs_FailedToBeSetupMod_Item; - /* 9.1 SRBs_FailedToBeSetupMod_Item */ - F1AP_SRBs_FailedToBeSetupMod_Item_t *srbs_failedToBeSetupMod_item= - &srbs_failedToBeSetupMod_item_ies->value.choice.SRBs_FailedToBeSetupMod_Item; - /* - sRBID */ - srbs_failedToBeSetupMod_item->sRBID = 50L; - asn1cCalloc(srbs_failedToBeSetupMod_item->cause, tmp) - tmp->present = F1AP_Cause_PR_radioNetwork; - tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - } + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie7->value.choice.SRBs_FailedToBeSetupMod_List.list, + F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t, srbs_failedToBeSetupMod_item_ies); + srbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_Item; + srbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; + srbs_failedToBeSetupMod_item_ies->value.present = F1AP_SRBs_FailedToBeSetupMod_ItemIEs__value_PR_SRBs_FailedToBeSetupMod_Item; + /* 9.1 SRBs_FailedToBeSetupMod_Item */ + F1AP_SRBs_FailedToBeSetupMod_Item_t *srbs_failedToBeSetupMod_item= + &srbs_failedToBeSetupMod_item_ies->value.choice.SRBs_FailedToBeSetupMod_Item; + /* - sRBID */ + srbs_failedToBeSetupMod_item->sRBID = 50L; + asn1cCalloc(srbs_failedToBeSetupMod_item->cause, tmp) + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; + } } /* optional */ /* c8. DRBs_FailedToBeSetupMod_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie8); - ie8->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; - ie8->criticality = F1AP_Criticality_reject; - ie8->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; + ie8->criticality = F1AP_Criticality_reject; + ie8->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeSetupMod_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie8->value.choice.DRBs_FailedToBeSetupMod_List.list, - F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t, drbs_failedToBeSetupMod_item_ies); - drbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_Item; - drbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; - drbs_failedToBeSetupMod_item_ies->value.present = F1AP_DRBs_FailedToBeSetupMod_ItemIEs__value_PR_DRBs_FailedToBeSetupMod_Item; - /* 10.1 DRBs_ToBeSetupMod_Item */ - F1AP_DRBs_FailedToBeSetupMod_Item_t *drbs_failedToBeSetupMod_item= - &drbs_failedToBeSetupMod_item_ies->value.choice.DRBs_FailedToBeSetupMod_Item; - /* dRBID */ - drbs_failedToBeSetupMod_item->dRBID = 30L; - drbs_failedToBeSetupMod_item->cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - drbs_failedToBeSetupMod_item->cause->present = F1AP_Cause_PR_radioNetwork; - drbs_failedToBeSetupMod_item->cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - } + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie8->value.choice.DRBs_FailedToBeSetupMod_List.list, + F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t, drbs_failedToBeSetupMod_item_ies); + drbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_Item; + drbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; + drbs_failedToBeSetupMod_item_ies->value.present = F1AP_DRBs_FailedToBeSetupMod_ItemIEs__value_PR_DRBs_FailedToBeSetupMod_Item; + /* DRBs_FailedToBeSetupMod_Item */ + F1AP_DRBs_FailedToBeSetupMod_Item_t *drbs_failedToBeSetupMod_item= + &drbs_failedToBeSetupMod_item_ies->value.choice.DRBs_FailedToBeSetupMod_Item; + /* dRBID */ + drbs_failedToBeSetupMod_item->dRBID = 30L; + drbs_failedToBeSetupMod_item->cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); + drbs_failedToBeSetupMod_item->cause->present = F1AP_Cause_PR_radioNetwork; + drbs_failedToBeSetupMod_item->cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; + } } /* optional */ /* c9. SCell_FailedtoSetupMod_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie9); - ie9->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List; - ie9->criticality = F1AP_Criticality_ignore; - ie9->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SCell_FailedtoSetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SCell_FailedtoSetupMod_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie9->value.choice.SCell_FailedtoSetupMod_List.list, - F1AP_SCell_FailedtoSetupMod_ItemIEs_t, scell_failedtoSetupMod_item_ies); - scell_failedtoSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_Item; - scell_failedtoSetupMod_item_ies->criticality = F1AP_Criticality_ignore; - scell_failedtoSetupMod_item_ies->value.present = F1AP_SCell_FailedtoSetupMod_ItemIEs__value_PR_SCell_FailedtoSetupMod_Item; - /* 8.1 SCell_ToBeSetup_Item */ - F1AP_SCell_FailedtoSetupMod_Item_t *scell_failedtoSetupMod_item=&scell_failedtoSetupMod_item_ies->value.choice.SCell_FailedtoSetupMod_Item; - /* - sCell_ID */ - addnRCGI(scell_failedtoSetupMod_item->sCell_ID, &f1ap_req(false, instance)->cell[i]); - asn1cCalloc(scell_failedtoSetupMod_item->cause, tmp); - tmp->present = F1AP_Cause_PR_radioNetwork; - tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - } + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie9->value.choice.SCell_FailedtoSetupMod_List.list, + F1AP_SCell_FailedtoSetupMod_ItemIEs_t, scell_failedtoSetupMod_item_ies); + scell_failedtoSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_Item; + scell_failedtoSetupMod_item_ies->criticality = F1AP_Criticality_ignore; + scell_failedtoSetupMod_item_ies->value.present = F1AP_SCell_FailedtoSetupMod_ItemIEs__value_PR_SCell_FailedtoSetupMod_Item; + /* 8.1 SCell_ToBeSetup_Item */ + F1AP_SCell_FailedtoSetupMod_Item_t *scell_failedtoSetupMod_item=&scell_failedtoSetupMod_item_ies->value.choice.SCell_FailedtoSetupMod_Item; + /* - sCell_ID */ + addnRCGI(scell_failedtoSetupMod_item->sCell_ID, &f1ap_req(false, instance)->cell[i]); + asn1cCalloc(scell_failedtoSetupMod_item->cause, tmp); + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; + } } /* optional */ /* c10. DRBs_FailedToBeModified_List */ if(0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie10); - ie10->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_List; - ie10->criticality = F1AP_Criticality_reject; - ie10->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeModified_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_List; + ie10->criticality = F1AP_Criticality_reject; + ie10->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeModified_List; - for (int i=0; i<1; i++) { - // - asn1cSequenceAdd(ie10->value.choice.DRBs_FailedToBeModified_List.list, - F1AP_DRBs_FailedToBeModified_ItemIEs_t, drbs_failedToBeModified_item_ies); - drbs_failedToBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_Item; - drbs_failedToBeModified_item_ies->criticality = F1AP_Criticality_reject; - drbs_failedToBeModified_item_ies->value.present = F1AP_DRBs_FailedToBeModified_ItemIEs__value_PR_DRBs_FailedToBeModified_Item; - /* 13.1 DRBs_FailedToBeModified_Item */ - F1AP_DRBs_FailedToBeModified_Item_t *drbs_failedToBeModified_item= - &drbs_failedToBeModified_item_ies->value.choice.DRBs_FailedToBeModified_Item ; - /* dRBID */ - drbs_failedToBeModified_item->dRBID = 30L; - asn1cCalloc(drbs_failedToBeModified_item->cause, tmp); - tmp->present = F1AP_Cause_PR_radioNetwork; - tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - } + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie10->value.choice.DRBs_FailedToBeModified_List.list, + F1AP_DRBs_FailedToBeModified_ItemIEs_t, drbs_failedToBeModified_item_ies); + drbs_failedToBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_Item; + drbs_failedToBeModified_item_ies->criticality = F1AP_Criticality_reject; + drbs_failedToBeModified_item_ies->value.present = F1AP_DRBs_FailedToBeModified_ItemIEs__value_PR_DRBs_FailedToBeModified_Item; + /* 13.1 DRBs_FailedToBeModified_Item */ + F1AP_DRBs_FailedToBeModified_Item_t *drbs_failedToBeModified_item= + &drbs_failedToBeModified_item_ies->value.choice.DRBs_FailedToBeModified_Item ; + /* dRBID */ + drbs_failedToBeModified_item->dRBID = 30L; + asn1cCalloc(drbs_failedToBeModified_item->cause, tmp); + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; + } } // /* */ @@ -1359,24 +1352,24 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* optional */ /* c12. SRBs_Setup_List */ if(resp->srbs_to_be_setup_length > 0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie12); - ie12->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_List; - ie12->criticality = F1AP_Criticality_ignore; - ie12->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_SetupMod_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_List; + ie12->criticality = F1AP_Criticality_ignore; + ie12->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_SetupMod_List; - for (int i=0; i< resp->srbs_to_be_setup_length; i++) {// - asn1cSequenceAdd(ie12->value.choice.SRBs_SetupMod_List.list, + for (int i=0; i< resp->srbs_to_be_setup_length; i++) {// + asn1cSequenceAdd(ie12->value.choice.SRBs_SetupMod_List.list, F1AP_SRBs_SetupMod_ItemIEs_t, srbs_setupmod_item_ies); - srbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_Item; - srbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; - srbs_setupmod_item_ies->value.present = F1AP_SRBs_SetupMod_ItemIEs__value_PR_SRBs_SetupMod_Item; - /* 11.1 SRBs_Setup_Item */ - /* ADD */ - F1AP_SRBs_SetupMod_Item_t *srbs_setupmod_item=&srbs_setupmod_item_ies->value.choice.SRBs_SetupMod_Item; - /* sRBID */ - srbs_setupmod_item->sRBID = resp->srbs_to_be_setup[i].srb_id; - srbs_setupmod_item->lCID = resp->srbs_to_be_setup[i].srb_id; - } + srbs_setupmod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_SetupMod_Item; + srbs_setupmod_item_ies->criticality = F1AP_Criticality_ignore; + srbs_setupmod_item_ies->value.present = F1AP_SRBs_SetupMod_ItemIEs__value_PR_SRBs_SetupMod_Item; + /* 11.1 SRBs_Setup_Item */ + /* ADD */ + F1AP_SRBs_SetupMod_Item_t *srbs_setupmod_item=&srbs_setupmod_item_ies->value.choice.SRBs_SetupMod_Item; + /* sRBID */ + srbs_setupmod_item->sRBID = resp->srbs_to_be_setup[i].srb_id; + srbs_setupmod_item->lCID = resp->srbs_to_be_setup[i].srb_id; + } } /* encode */ diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2d5b9466f7..d4e1ff8941 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3668,6 +3668,7 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, c sizeof(*cellGroupConfig->rlc_BearerToAddModList)); } } + LOG_I(NR_RRC, "Updated master cell group configuration stored at the UE context of the CU:\n"); xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, cellGroupConfig); From 85faedfcbe2f74173246af6fa464d764ae939c03 Mon Sep 17 00:00:00 2001 From: matzakos Date: Mon, 18 Oct 2021 18:32:57 +0200 Subject: [PATCH 12/84] Add triggering of F1 UE Context release command -Add also a temporary artificial trigger just to be able to test with OAI UE -Comment out most of the part of the UE context release command handler function at the DU in order to separate properly the RRC from F1AP functionality later. --- openair2/F1AP/f1ap_cu_ue_context_management.c | 12 +++--- openair2/F1AP/f1ap_du_ue_context_management.c | 22 +++++----- openair2/RRC/NR/rrc_gNB.c | 40 +++++++++++++++---- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 2e2ee1e0ac..141d89ac51 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -907,12 +907,14 @@ int CU_send_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, /* optional */ /* c4. RRCContainer */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie4); - ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie4->criticality = F1AP_Criticality_ignore; - ie4->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *)cmd->rrc_container, + if(cmd->rrc_container!=NULL){ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie4->criticality = F1AP_Criticality_ignore; + ie4->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *)cmd->rrc_container, cmd->rrc_container_length); + } /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index ce47fec196..77f8b9d046 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -683,14 +683,14 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, protocol_ctxt_t ctxt; DevAssert(pdu); container = &pdu->choice.initiatingMessage->value.choice.UEContextReleaseCommand; - /* GNB_CU_UE_F1AP_ID */ + // GNB_CU_UE_F1AP_ID F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); ctxt.rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID); ctxt.instance = instance; ctxt.module_id = instance; ctxt.enb_flag = 1; - /* GNB_DU_UE_F1AP_ID */ + // GNB_DU_UE_F1AP_ID F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); const rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, @@ -700,7 +700,7 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, rnti, ctxt.rnti); int UE_out_of_sync = 0; - if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + /*if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { if (RC.nrmac[instance]->UE_info.active[n] == TRUE && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { @@ -718,13 +718,13 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, } } - /* We don't need the Cause */ - /* Optional RRC Container: if present, send to UE */ + // We don't need the Cause + // Optional RRC Container: if present, send to UE F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_RRCContainer, false); if (ie && !UE_out_of_sync) { - /* RRC message and UE is reachable, send message */ + // RRC message and UE is reachable, send message const sdu_size_t sdu_len = ie->value.choice.RRCContainer.size; mem_block_t *pdu_p = NULL; pdu_p = get_free_mem_block(sdu_len, __func__); @@ -775,8 +775,8 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.instance], ctxt.rnti); if (ue_context_p && !UE_out_of_sync) { - /* UE exists and is in sync so we start a timer before releasing the - * connection */ + // UE exists and is in sync so we start a timer before releasing the + // connection pthread_mutex_lock(&rrc_release_freelist); for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { @@ -800,18 +800,18 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, pthread_mutex_unlock(&rrc_release_freelist); ue_context_p->ue_context.ue_release_timer_s1 = 0; } else if (ue_context_p && UE_out_of_sync) { - /* UE exists and is out of sync, drop the connection */ + // UE exists and is out of sync, drop the connection mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti); } else { LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti); } - /* TODO send this once the connection has really been released */ + // TODO send this once the connection has really been released f1ap_ue_context_release_cplt_t cplt; cplt.rnti = ctxt.rnti; DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); return 0; - } + }*/ } int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, f1ap_ue_context_release_cplt_t *cplt) { diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d4e1ff8941..a18b267ec6 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1515,6 +1515,18 @@ rrc_gNB_process_RRCReconfigurationComplete( free(DRB_Release_configList2); ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL; } + //Temporarily trigger artificially UE context release for the CU case just to be able to test it with OAI UE. To be removed later + if(0){ + if(NODE_IS_CU(RC.nrrrc[ctxt_pP->instance]->node_type)){ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); + f1ap_ue_context_release_cmd_t *rel_cmd=&F1AP_UE_CONTEXT_RELEASE_CMD (message_p); + rel_cmd->rnti = ctxt_pP->rnti; + rel_cmd->cause = F1AP_CAUSE_RADIO_NETWORK; + rel_cmd->cause_value = 10; // 10 = F1AP_CauseRadioNetwork_normal_release + itti_send_msg_to_task(TASK_CU_F1, ctxt_pP->module_id, message_p); + } + } } //----------------------------------------------------------------------------- @@ -3925,15 +3937,27 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { // Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G if(ue_context_p->ue_context.StatusRrc < NR_RRC_CONNECTED || ue_context_p->ue_context.gNB_ue_ngap_id == 0) { - mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); - rrc_rlc_remove_ue(ctxt_pP); - pdcp_remove_UE(ctxt_pP); + if(!NODE_IS_CU(RC.nrrrc[ctxt_pP->instance]->node_type)){ + mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + rrc_rlc_remove_ue(ctxt_pP); + pdcp_remove_UE(ctxt_pP); - /* remove RRC UE Context */ - ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rnti); - if (ue_context_p) { - rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); - LOG_I(NR_RRC, "remove UE %x \n", ctxt_pP->rnti); + /* remove RRC UE Context */ + ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rnti); + if (ue_context_p) { + rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); + LOG_I(NR_RRC, "remove UE %x \n", ctxt_pP->rnti); + } + } + // In case of CU trigger UE context release command towards the DU + else{ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); + f1ap_ue_context_release_cmd_t *rel_cmd=&F1AP_UE_CONTEXT_RELEASE_CMD (message_p); + rel_cmd->rnti = ctxt_pP->rnti; + rel_cmd->cause = F1AP_CAUSE_RADIO_NETWORK; + rel_cmd->cause_value = 10; // 10 = F1AP_CauseRadioNetwork_normal_release + itti_send_msg_to_task(TASK_CU_F1, ctxt_pP->module_id, message_p); } } From 11cdf1610ec79f31ae9578b1fd60433202eda383 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 20 Oct 2021 19:00:51 +0200 Subject: [PATCH 13/84] Update F1AP UE context release command handling function for NR -Include ITTI message to RRC to do the actual processing at RRC layer, as done for the other F1AP messages. Leave LTE processing as it was for now. --- openair2/F1AP/f1ap_du_ue_context_management.c | 185 +++++++++++++++++- openair2/RRC/NR/rrc_gNB.c | 5 + 2 files changed, 187 insertions(+), 3 deletions(-) diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 77f8b9d046..92e8e272da 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -674,7 +674,7 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, getCxt(false, instance)->default_sctp_stream_id); return 0; } -int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, +/*int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { @@ -700,7 +700,7 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, rnti, ctxt.rnti); int UE_out_of_sync = 0; - /*if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { if (RC.nrmac[instance]->UE_info.active[n] == TRUE && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { @@ -811,8 +811,187 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, cplt.rnti = ctxt.rnti; DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); return 0; - }*/ + } +}*/ + + +int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { + F1AP_UEContextReleaseCommand_t *container; + F1AP_UEContextReleaseCommandIEs_t *ie; + protocol_ctxt_t ctxt; + + /* ITTI message to NR-RRC for the case of gNB-DU */ + MessageDef *msg_p; // message to NR-RRC + msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_RELEASE_CMD); + f1ap_ue_context_release_req_t *f1ap_ue_context_release_cmd = &F1AP_UE_CONTEXT_RELEASE_CMD(msg_p); + + + DevAssert(pdu); + container = &pdu->choice.initiatingMessage->value.choice.UEContextReleaseCommand; + // GNB_CU_UE_F1AP_ID + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); + if(RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU){ + f1ap_ue_context_release_cmd->rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID); + } + else{ + ctxt.rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID); + ctxt.instance = instance; + ctxt.module_id = instance; + ctxt.enb_flag = 1; + } + // GNB_DU_UE_F1AP_ID + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); + const rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, + ie->value.choice.GNB_DU_UE_F1AP_ID); + if(RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU){ + AssertFatal(f1ap_ue_context_release_cmd->rnti == rnti, + "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", + rnti, f1ap_ue_context_release_cmd->rnti); + } + else{ + AssertFatal(ctxt.rnti == rnti, + "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", + rnti, ctxt.rnti); + } + int UE_out_of_sync = 0; + + if(RC.rrc && RC.rrc[instance]->node_type == ngran_eNB_DU){ + for (int n = 0; n < MAX_MOBILES_PER_ENB; ++n) { + if (RC.mac[instance]->UE_info.active[n] == TRUE + && rnti == UE_RNTI(instance, n)) { + UE_out_of_sync = RC.mac[instance]->UE_info.UE_sched_ctrl[n].ul_out_of_sync; + break; + } + } + } + + // We don't need the Cause + // Optional RRC Container: if present, send to UE + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_RRCContainer, false); + + if (ie && !UE_out_of_sync && RC.rrc && RC.rrc[instance]->node_type == ngran_eNB_DU) { + // RRC message and UE is reachable, send message + const sdu_size_t sdu_len = ie->value.choice.RRCContainer.size; + mem_block_t *pdu_p = NULL; + pdu_p = get_free_mem_block(sdu_len, __func__); + memcpy(&pdu_p->data[0], ie->value.choice.RRCContainer.buf, sdu_len); + rlc_op_status_t rlc_status = rlc_data_req(&ctxt + , 1 + , MBMS_FLAG_NO + , 1 // SRB 1 correct? + , 0 + , 0 + , sdu_len + , pdu_p + ,NULL + ,NULL + ); + + switch (rlc_status) { + case RLC_OP_STATUS_OK: + break; + + case RLC_OP_STATUS_BAD_PARAMETER: + LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); + break; + + case RLC_OP_STATUS_INTERNAL_ERROR: + LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); + break; + + case RLC_OP_STATUS_OUT_OF_RESSOURCES: + LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); + break; + + default: + LOG_W(F1AP, "RLC returned an unknown status code after F1AP placed " + "the order to send some data (Status Code:%d)\n", rlc_status); + break; + } + } + else if(ie && RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + f1ap_ue_context_release_cmd->rrc_container = malloc(ie->value.choice.RRCContainer.size); + memcpy(f1ap_ue_context_release_cmd->rrc_container, + ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); + } + + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_Cause, true); + switch (ie->value.choice.Cause.present){ + case F1AP_Cause_PR_radioNetwork: + LOG_W (F1AP, "UE context release command cause is due to radioNetwork with specific code: %ld\n",ie->value.choice.Cause.choice.radioNetwork); + f1ap_ue_context_release_cmd->cause = F1AP_CAUSE_RADIO_NETWORK; + break; + case F1AP_Cause_PR_transport: + LOG_W (F1AP, "UE context release command cause is due to transport with specific code: %ld\n",ie->value.choice.Cause.choice.transport); + f1ap_ue_context_release_cmd->cause = F1AP_CAUSE_TRANSPORT; + break; + case F1AP_Cause_PR_protocol: + LOG_W (F1AP, "UE context release command cause is due to protocol with specific code: %ld\n",ie->value.choice.Cause.choice.protocol); + f1ap_ue_context_release_cmd->cause = F1AP_CAUSE_PROTOCOL; + break; + case F1AP_Cause_PR_misc: + LOG_W (F1AP, "UE context release command cause is misc with specific code: %ld \n",ie->value.choice.Cause.choice.misc); + f1ap_ue_context_release_cmd->cause = F1AP_CAUSE_MISC; + break; + default: + LOG_W(F1AP, "Unknown cause for UE context release command\n"); + break; + + } + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); + return 0; + } else { + struct rrc_eNB_ue_context_s *ue_context_p; + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.instance], ctxt.rnti); + + if (ue_context_p && !UE_out_of_sync) { + // UE exists and is in sync so we start a timer before releasing the + // connection + pthread_mutex_lock(&rrc_release_freelist); + + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { + if (ue_context_p->ue_context.ue_release_timer_s1 > 0) + rrc_release_info.RRC_release_ctrl[release_num].flag = 1; + else + rrc_release_info.RRC_release_ctrl[release_num].flag = 2; + + rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt.rnti; + LOG_D(F1AP, "add rrc_release_info RNTI %x\n", ctxt.rnti); + // TODO: how to provide the correct MUI? + rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = 0; + rrc_release_info.num_UEs++; + LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, + ctxt.rnti, 0, rrc_release_info.RRC_release_ctrl[release_num].flag); + break; + } + } + + pthread_mutex_unlock(&rrc_release_freelist); + ue_context_p->ue_context.ue_release_timer_s1 = 0; + } else if (ue_context_p && UE_out_of_sync) { + // UE exists and is out of sync, drop the connection + mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti); + } else { + LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti); + } + + // TODO send this once the connection has really been released + f1ap_ue_context_release_cplt_t cplt; + cplt.rnti = ctxt.rnti; + DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); + return 0; + } } + int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, f1ap_ue_context_release_cplt_t *cplt) { F1AP_F1AP_PDU_t pdu= {0}; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a18b267ec6..25f058c1d2 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -4212,6 +4212,11 @@ void *rrc_gnb_task(void *args_p) { rrc_DU_process_ue_context_modification_request(msg_p, msg_name_p, instance); break; + case F1AP_UE_CONTEXT_RELEASE_CMD: + LOG_W(NR_RRC, "Received F1AP_UE_CONTEXT_RELEASE_CMD for processing at the RRC layer of the DU. Processing function " + "implementation is pending\n"); + break; + /* Messages from X2AP */ case X2AP_ENDC_SGNB_ADDITION_REQ: LOG_I(NR_RRC, "Received ENDC sgNB addition request from X2AP \n"); From 96efe9c03b5f2b146bfabdb709bddd58eaf738cf Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 26 Oct 2021 12:56:32 +0200 Subject: [PATCH 14/84] Enable rrc mac config from init NR SI for the DU case --- openair2/RRC/NR/rrc_gNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 25f058c1d2..58a0f4b0c9 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -257,7 +257,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration LOG_I(NR_RRC,"Done init_NR_SI\n"); - if (NODE_IS_MONOLITHIC(rrc->node_type)){ + if (NODE_IS_MONOLITHIC(rrc->node_type) || NODE_IS_DU(rrc->node_type)){ rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, rrc->carrier.pdsch_AntennaPorts, From e7f8b56b65186d5f7f09a13e8a44740153037ae2 Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 26 Oct 2021 12:57:47 +0200 Subject: [PATCH 15/84] Include NR_SIB1_t type in F1 setup req container instead of the whole NR_BCCH_DL_SCH_Message_t message -Wireshark is not complaining after that -Issue at decoding F1 Setup req at the CU due to the new encoding -Keep the previous encoding as the default for now until the CU issue is fixed -Fix PUCCH allocation for ACK/NAK issue appearing when DU runs without OAI CU --- openair2/GNB_APP/gnb_config.c | 38 ++++++++++++++++++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index bcce5a367a..a2e418245a 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1735,9 +1735,43 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { f1Setup->measurement_timing_information[k] = "0"; f1Setup->ranac[k] = 0; f1Setup->mib[k] = rrc->carrier.MIB; - f1Setup->sib1[k] = rrc->carrier.SIB1; f1Setup->mib_length[k] = rrc->carrier.sizeof_MIB; - f1Setup->sib1_length[k] = rrc->carrier.sizeof_SIB1; + if(1){ + f1Setup->sib1[k] = rrc->carrier.SIB1; + f1Setup->sib1_length[k] = rrc->carrier.sizeof_SIB1; + } + else{ + NR_BCCH_DL_SCH_Message_t *bcch_message = NULL; + + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_BCCH_DL_SCH_Message, + (void **)&bcch_message, + (const void *)rrc->carrier.SIB1, + rrc->carrier.sizeof_SIB1); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + LOG_E(RRC,"SIB1 decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_BCCH_DL_SCH_Message, bcch_message, 1 ); + exit(1); + } + + NR_SIB1_t *bcch_SIB1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; + f1Setup->sib1[k] = calloc(1,rrc->carrier.sizeof_SIB1); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_SIB1, + NULL, + (void *)bcch_SIB1, + f1Setup->sib1[k], + NR_MAX_SIB_LENGTH/8); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + LOG_I(NR_RRC, "SIB1 container to be integrated in F1 Setup request:\n"); + xer_fprint(stdout, &asn_DEF_NR_SIB1,(void *)bcch_message->message.choice.c1->choice.systemInformationBlockType1 ); + //} + f1Setup->sib1_length[k] = (enc_rval.encoded+7)/8; + } break; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 606da48575..dc4d187842 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1463,7 +1463,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch); - AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); + AssertFatal(alloc>=0,"%d.%d Couldn't find a pucch allocation for ack nack (msg4), r_pucch %d (CCEindex%d,N_cce%d\n",frameP,slotP,r_pucch,CCEIndex,N_cce); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; harq->feedback_slot = pucch->ul_slot; harq->feedback_frame = pucch->frame; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 0f828b8e81..6fcc3fe5c1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1355,7 +1355,7 @@ int nr_acknack_scheduling(int mod_id, * for initialCyclicShift 0 (we assume it always has that one), so other * initialCyclicShifts can overlap with ICS 0!*/ if (pucch_Config==NULL) - return -1; + return 0; const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); if (resource->format.choice.format0->initialCyclicShift == 0) { From b103ada5421f4ca46ac9d52e554a9694b95dd933 Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 26 Oct 2021 18:30:51 +0200 Subject: [PATCH 16/84] Fix decoding of SIB1 RRC container at the processing function of F1 setup request at the CU after modifications done at the encoded SIB1 message type included in the RRC container of F1 setup request at the DU -Some cleanup required --- openair2/GNB_APP/gnb_config.c | 2 +- openair2/RRC/NR/nr_rrc_defs.h | 3 ++- openair2/RRC/NR/rrc_gNB.c | 16 +++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index a2e418245a..29f3c15355 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1736,7 +1736,7 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { f1Setup->ranac[k] = 0; f1Setup->mib[k] = rrc->carrier.MIB; f1Setup->mib_length[k] = rrc->carrier.sizeof_MIB; - if(1){ + if(0){ f1Setup->sib1[k] = rrc->carrier.SIB1; f1Setup->sib1_length[k] = rrc->carrier.sizeof_SIB1; } diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 4418a37632..19120e8854 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -440,7 +440,8 @@ typedef struct { NR_BCCH_BCH_Message_t mib; NR_BCCH_BCH_Message_t *mib_DU; - NR_BCCH_DL_SCH_Message_t *siblock1_DU; + NR_SIB1_t *siblock1_DU; + //NR_BCCH_DL_SCH_Message_t *siblock1_DU; NR_SIB1_t *sib1; NR_SIB2_t *sib2; NR_SIB3_t *sib3; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 58a0f4b0c9..c618468cd9 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2895,11 +2895,11 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { memset(mib->message.choice.mib,0,sizeof(struct NR_MIB)); memcpy(mib->message.choice.mib, mib_DU->message.choice.mib, sizeof(struct NR_MIB)); - rrc->carrier.SIB1 = malloc(f1_setup_req->sib1_length[i]); + /*rrc->carrier.SIB1 = malloc(f1_setup_req->sib1_length[i]); rrc->carrier.sizeof_SIB1 = f1_setup_req->sib1_length[i]; - memcpy((void *)rrc->carrier.SIB1,f1_setup_req->sib1[i],f1_setup_req->sib1_length[i]); + memcpy((void *)rrc->carrier.SIB1,f1_setup_req->sib1[i],f1_setup_req->sib1_length[i]);*/ dec_rval = uper_decode_complete(NULL, - &asn_DEF_NR_BCCH_DL_SCH_Message, + &asn_DEF_NR_SIB1, //&asn_DEF_NR_BCCH_DL_SCH_Message, (void **)&rrc->carrier.siblock1_DU, f1_setup_req->sib1[i], f1_setup_req->sib1_length[i]); @@ -2909,12 +2909,18 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { dec_rval.consumed ); // Parse message and extract SystemInformationBlockType1 field - NR_BCCH_DL_SCH_Message_t *bcch_message = rrc->carrier.siblock1_DU; + rrc->carrier.sib1 = rrc->carrier.siblock1_DU; + if ( LOG_DEBUGFLAG(DEBUG_ASN1)){ + LOG_I(NR_RRC, "Printing received SIB1 container inside F1 setup request message:\n"); + xer_fprint(stdout, &asn_DEF_NR_SIB1,(void *)rrc->carrier.sib1); + } + + /*NR_BCCH_DL_SCH_Message_t *bcch_message = rrc->carrier.siblock1_DU; AssertFatal(bcch_message->message.present == NR_BCCH_DL_SCH_MessageType_PR_c1, "bcch_message->message.present != NR_BCCH_DL_SCH_MessageType_PR_c1\n"); AssertFatal(bcch_message->message.choice.c1->present == NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1, "bcch_message->message.choice.c1->present != NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1\n"); - rrc->carrier.sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; + rrc->carrier.sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1;*/ rrc->carrier.physCellId = f1_setup_req->cell[i].nr_pci; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).gNB_CU_name = rrc->node_name; From e2b4f80ac23b391f7d5eaca468c95165f39261e2 Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 5 Nov 2021 10:38:46 +0100 Subject: [PATCH 17/84] Add sNSSAI configuration in F1 Setup request message to the CU -Required for interoperability with Accelleran CU and OAI CN -Currently hardcoded values, to be modified so that they are parsed from the DU config file -After this modification Accelleran CU sends gNBCU configuration update --- openair2/F1AP/f1ap_du_interface_management.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 12b0559003..e6631e1edb 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -175,6 +175,24 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { MCC_MNC_TO_PLMNID(cell->mcc, cell->mnc, cell->mnc_digit_length, &servedPLMN_item->pLMN_Identity); // // /* - CHOICE NR-MODE-Info */ F1AP_NR_Mode_Info_t *nR_Mode_Info= &served_cell_information->nR_Mode_Info; + //if(0){ + //F1AP_ProtocolExtensionContainer_154P260_t *p_154P260=calloc(1, sizeof(* p_154P260)); + F1AP_ProtocolExtensionContainer_154P34_t *p_154P34=calloc(1,sizeof(* p_154P34)); + servedPLMN_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p_154P34; + asn1cSequenceAdd(p_154P34->list, F1AP_ServedPLMNs_ItemExtIEs_t , served_plmns_itemExtIEs); + served_plmns_itemExtIEs->criticality = F1AP_Criticality_ignore; + served_plmns_itemExtIEs->id = F1AP_ProtocolIE_ID_id_TAISliceSupportList; + served_plmns_itemExtIEs->extensionValue.present = F1AP_ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList; + F1AP_SliceSupportList_t *slice_support_list = &served_plmns_itemExtIEs->extensionValue.choice.SliceSupportList; + + asn1cSequenceAdd(slice_support_list->list, F1AP_SliceSupportItem_t, SliceSupport_item); + INT8_TO_OCTET_STRING(1,&SliceSupport_item->sNSSAI.sST); + //OCTET_STRING_fromBuf(&SliceSupport_item->sNSSAI.sST, "1", 1); + asn1cCalloc(SliceSupport_item->sNSSAI.sD, tmp); + INT24_TO_OCTET_STRING(1,tmp); + //OCTET_STRING_fromBuf(tmp, "1",1); + //} + if (f1ap_req(false, instance)->fdd_flag) { // FDD nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD; From 6a1ac1444766c2af61f1a3e8bb89a9e763e16ce8 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 10 Nov 2021 18:31:08 +0100 Subject: [PATCH 18/84] Include mandatory transaction ID field in F1 initial UL RRC message transfer --- openair2/F1AP/f1ap_du_rrc_message_transfer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index ac281af81d..59445d792d 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -812,6 +812,13 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, sdu2P, sdu2_lenP); } + /* mandatory */ + /* c6. Transaction ID (integer value) */ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_TransactionID; + ie6->criticality = F1AP_Criticality_ignore; + ie6->value.present = F1AP_F1SetupRequestIEs__value_PR_TransactionID; + ie6->value.choice.TransactionID = F1AP_get_next_transaction_identifier(f1ap_req(false, instanceP)->gNB_DU_id, f1ap_req(false, instanceP)->gNB_DU_id); /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { From f1455f15a3e184139ac3bbb92f43e65ac8f5e390 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 10 Nov 2021 18:33:48 +0100 Subject: [PATCH 19/84] Check whether RRC Setup is available before sending CBRA Msg4 -Required for the CU/DU split case if the RRC Setup arrives later than the first opportunity to transmit Msg4 -Next extension is to decouple RRCSetup from Msg4 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 5 +++++ openair2/RRC/NR/L2_nr_interface.c | 8 ++++++++ openair2/RRC/NR/nr_rrc_proto.h | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index dc4d187842..26ef47f152 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1388,6 +1388,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { + if (nr_mac_rrc_check_RRCSetup(module_idP, ra->rnti) <= 0){ + ra->Msg4_frame++; + return; + } + uint8_t time_domain_assignment = 0; uint8_t mcsIndex = 0; diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 445aa832cb..dd9a5bb188 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -304,6 +304,14 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, } +int8_t nr_mac_rrc_check_RRCSetup(const module_id_t Mod_idP, + const rnti_t rnti) { + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti); + char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size; + return payload_size; + +} + int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, const int CC_id, const frame_t frameP, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 2ac8d14a23..771845d5d0 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -170,6 +170,12 @@ nr_rrc_data_req( const pdcp_transmission_mode_t modeP ); +int8_t nr_mac_rrc_check_RRCSetup( + const module_id_t Mod_idP, + const rnti_t rnti + +); + int nr_rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP); From cd16d7ce0386173594a43b8102a95d9eca10b120 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 10 Nov 2021 18:35:05 +0100 Subject: [PATCH 20/84] Make the call to send DCCH SDU to RLC from RRC instead of F1AP --- openair2/F1AP/f1ap_du_ue_context_management.c | 10 +--------- openair2/RRC/NR/rrc_gNB.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 92e8e272da..1a4fbe38a5 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -230,17 +230,9 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, f1ap_ue_context_setup_req->rrc_container = malloc(ieRRC->value.choice.RRCContainer.size); memcpy(f1ap_ue_context_setup_req->rrc_container, ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); + f1ap_ue_context_setup_req->rrc_container_length = ieRRC->value.choice.RRCContainer.size; // AssertFatal(0, "check configuration, send to appropriate handler\n"); protocol_ctxt_t ctxt; - // decode RRC Container and act on the message type - //FIXME - //rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); - ctxt.instance = instance; - ctxt.instance = instance; - ctxt.enb_flag = 1; - mem_block_t *pdcp_pdu_p = get_free_mem_block(ieRRC->value.choice.RRCContainer.size, __func__); - memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); - du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p); } else { LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n"); } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index c618468cd9..c3f415ee64 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3393,8 +3393,20 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha req->srbs_to_be_setup_length>0 ? 1:0, req->drbs_to_be_setup_length>0 ? 1:0); } - + apply_macrlc_config(rrc, ue_context_p, &ctxt); + + if(req->rrc_container_length > 0){ + mem_block_t *pdcp_pdu_p = get_free_mem_block(req->rrc_container_length, __func__); + memcpy(&pdcp_pdu_p->data[0], req->rrc_container, req->rrc_container_length); + du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, req->rrc_container_length, pdcp_pdu_p); + LOG_I(F1AP, "Printing RRC Container of UE context setup request: \n"); + for (int j=0; jrrc_container_length; j++){ + printf("%02x ", pdcp_pdu_p->data[j]); + } + printf("\n"); + } + /* Fill the UE context setup response ITTI message to send to F1AP */ resp->gNB_CU_ue_id = req->gNB_CU_ue_id; resp->rnti = ctxt.rnti; @@ -4526,5 +4538,6 @@ void nr_rrc_trigger(protocol_ctxt_t *ctxt, int CC_id, int frame, int subframe) message_p = itti_alloc_new_message(TASK_RRC_GNB, 0, RRC_SUBFRAME_PROCESS); RRC_SUBFRAME_PROCESS(message_p).ctxt = *ctxt; RRC_SUBFRAME_PROCESS(message_p).CC_id = CC_id; + LOG_D(NR_RRC, "Time in RRC: %u/ %u \n", frame, subframe); itti_send_msg_to_task(TASK_RRC_GNB, ctxt->module_id, message_p); } From 188a99ca518a17113abc588fc6ca098e3d26237b Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 10 Nov 2021 18:35:52 +0100 Subject: [PATCH 21/84] Temporary dirty fix to not block SRB1 traffic once SRB2 is added -This function will change completely after update with develop --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 2cbe232fe0..9e9e105ba0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -395,8 +395,14 @@ void nr_store_dlsch_buffer(module_id_t module_id, loop_dcch_dtch = DL_SCH_LCID_DTCH; else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DTCH) loop_dcch_dtch = DL_SCH_LCID_DCCH; - else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH) - loop_dcch_dtch = DL_SCH_LCID_DCCH1; + /*else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH) + loop_dcch_dtch = DL_SCH_LCID_DCCH1;*/ + else if ((sched_ctrl->lcid_mask&(1<<2)) > 0){ //&& loop_dcch_dtch == DL_SCH_LCID_DCCH + if (loop_dcch_dtch == DL_SCH_LCID_DCCH) + loop_dcch_dtch = DL_SCH_LCID_DCCH1; + else if(loop_dcch_dtch == DL_SCH_LCID_DCCH1) + loop_dcch_dtch = DL_SCH_LCID_DCCH; + } const int lcid = loop_dcch_dtch; // const int lcid = DL_SCH_LCID_DTCH; @@ -788,6 +794,10 @@ void nr_schedule_ue_spec(module_id_t module_id, return; /* PREPROCESSOR */ + //Following commented section condition should be removed before update with develop. + /*if(slot!= 1 && slot!=11){ + return; + }*/ gNB_mac->pre_processor_dl(module_id, frame, slot); const int CC_id = 0; From 40263348f96ead12dac9626bb30639f1b47d4be7 Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 12 Nov 2021 17:01:27 +0100 Subject: [PATCH 22/84] Merge with NR_F1C_F1U_extensions and resolve conflicts --- ci-scripts/Jenkinsfile-GitLab-Container | 17 + ci-scripts/Jenkinsfile-push-registry | 86 ++ ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 15 + ci-scripts/Jenkinsfile-trig-nsa | 44 +- ci-scripts/ci_ueinfra.yaml | 15 +- ci-scripts/cls_containerize.py | 17 +- ci-scripts/cls_module_ue.py | 31 +- ci-scripts/cls_oaicitest.py | 289 +++++-- ci-scripts/conf_files/channelmod_rfsimu.conf | 2 +- .../enb.band38.lte_2x2.100PRB.usrpn310.conf | 281 ++++++ .../enb.band38.nsa_2x2.100PRB.usrpn310.conf | 9 +- .../gNB_SA_n78_106PRB.2x2_usrpn310.conf | 338 ++++++++ .../gNB_SA_n78_133PRB.2x2_usrpn310.conf | 334 ++++++++ .../gnb.band261.tm1.32PRB.usrpn300.conf | 20 +- .../gnb.band66.tm1.106PRB.usrpn300.conf | 17 + .../gnb.band78.nsa_2x2.106PRB.usrpn310.conf | 25 +- ...gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf | 340 ++++++++ .../gnb.band78.sa.fr1.106PRB.usrpn310.conf | 45 +- .../gnb.band78.tm1.106PRB.usrpn300.conf | 18 +- .../gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 17 + .../gnb.band78.tm1.fr1.106PRB.usrpn310.conf | 17 + ci-scripts/datalog_rt_stats.yaml | 6 +- ci-scripts/epc.py | 116 ++- ci-scripts/main.py | 1 + ci-scripts/ran.py | 55 +- ci-scripts/sshconnection.py | 12 + ci-scripts/stats_monitor.py | 102 +++ ci-scripts/stats_monitor.py.old | 94 ++ ci-scripts/stats_monitor_conf.yaml | 11 + ci-scripts/stats_monitor_dev.py | 101 +++ ci-scripts/xml_files/fr1_enb_build.xml | 50 ++ ci-scripts/xml_files/fr1_gnb_build.xml | 2 - ci-scripts/xml_files/fr1_lte_2x2_quectel.xml | 141 +++ ci-scripts/xml_files/fr1_multi_node_build.xml | 7 +- ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml | 30 +- .../fr1_nsa_2x2_quectel_attach_detach.xml | 145 ++++ ci-scripts/xml_files/fr1_oai_cn_deploy.xml | 2 +- ci-scripts/xml_files/fr1_sa_quectel.xml | 16 +- .../docker-compose.yml | 19 +- .../docker-compose.yml} | 139 ++- .../yaml_files/magma_nsa_20897/entrypoint.sh | 36 + .../yaml_files/magma_nsa_20897/mme.conf | 136 +++ .../magma_nsa_20897/mme_fd.sprint.conf | 169 ++++ .../magma_nsa_20897/redis_extern.conf | 33 + cmake_targets/CMakeLists.txt | 86 +- cmake_targets/build_oai | 2 +- cmake_targets/tools/build_helper | 53 +- common/utils/DOC/loader/devusage/api.md | 4 + common/utils/load_module_shlib.c | 11 +- common/utils/load_module_shlib.h | 5 +- common/utils/nr/nr_common.c | 196 +++++ common/utils/nr/nr_common.h | 7 + common/utils/telnetsrv/telnetsrv.c | 139 ++- common/utils/telnetsrv/telnetsrv.h | 2 + .../telnetsrv/telnetsrv_5Gue_measurements.c | 178 ++++ .../utils/telnetsrv/telnetsrv_CMakeLists.txt | 6 +- .../utils/telnetsrv/telnetsrv_cpumeasur_def.h | 162 ++-- .../utils/telnetsrv/telnetsrv_measurements.c | 101 ++- .../utils/telnetsrv/telnetsrv_measurements.h | 8 +- doc/BUILD.md | 15 + doc/RUNMODEM.md | 5 +- doc/testing_gnb_w_cots_ue_resources/gnb.conf | 17 + docker/Dockerfile.eNB.rhel8.2 | 17 +- docker/Dockerfile.eNB.ubuntu18 | 28 +- docker/Dockerfile.gNB.rhel8.2 | 17 +- docker/Dockerfile.gNB.ubuntu18 | 24 +- docker/Dockerfile.lteRU.rhel8.2 | 16 +- docker/Dockerfile.lteRU.ubuntu18 | 27 +- docker/Dockerfile.lteUE.rhel8.2 | 17 +- docker/Dockerfile.lteUE.ubuntu18 | 29 +- docker/Dockerfile.nrUE.rhel8.2 | 16 +- docker/Dockerfile.nrUE.ubuntu18 | 26 +- docker/Dockerfile.ran.rhel8.2 | 3 + docker/Dockerfile.ran.ubuntu18 | 5 +- docker/scripts/enb_entrypoint.sh | 6 +- docker/scripts/gnb_entrypoint.sh | 6 +- docker/scripts/lte_ru_entrypoint.sh | 6 +- docker/scripts/lte_ue_entrypoint.sh | 6 +- docker/scripts/nr_ue_entrypoint.sh | 6 +- executables/nr-gnb.c | 87 +- executables/nr-ru.c | 301 ++++--- executables/nr-uesoftmodem.c | 8 +- executables/nr-uesoftmodem.h | 2 +- executables/softmodem-common.h | 8 +- nfapi/oai_integration/nfapi_pnf.c | 85 +- openair1/PHY/CODING/DOC/LDPCImplementation.md | 163 +++- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 51 +- .../CODING/nrLDPC_decoder/nrLDPC_decoder.c | 6 +- .../CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c | 436 ++++++++++ .../nrLDPC_decoder_kernels_CL.cl | 302 +++++++ .../PHY/CODING/nrLDPC_decoder/nrLDPC_types.h | 1 + .../nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu | 59 +- openair1/PHY/CODING/nrLDPC_defs.h | 3 +- openair1/PHY/CODING/nrLDPC_extern.h | 7 +- openair1/PHY/CODING/nrLDPC_load.c | 26 +- .../CODING/nrPolar_tools/nr_polar_encoder.c | 25 +- openair1/PHY/CODING/nr_segmentation.c | 10 +- openair1/PHY/INIT/nr_init.c | 48 +- openair1/PHY/INIT/nr_init_ru.c | 18 +- openair1/PHY/INIT/nr_parms.c | 5 +- openair1/PHY/INIT/phy_init.h | 1 + openair1/PHY/LTE_TRANSPORT/if5_tools.c | 199 ++--- openair1/PHY/MODULATION/slot_fep_nr.c | 25 +- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 115 ++- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 43 +- openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h | 2 +- openair1/PHY/NR_REFSIG/nr_gold.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 23 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 2 - openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 107 +-- .../PHY/NR_TRANSPORT/nr_dci_tools_common.c | 62 -- openair1/PHY/NR_TRANSPORT/nr_dlsch.c | 18 +- openair1/PHY/NR_TRANSPORT/nr_dlsch.h | 8 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c | 38 +- openair1/PHY/NR_TRANSPORT/nr_prach_common.c | 1 - openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c | 2 +- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 3 +- openair1/PHY/NR_TRANSPORT/nr_ulsch.c | 24 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 29 +- .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 86 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 803 ++++++++++-------- .../PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 1 - openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 45 +- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 5 - .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 84 +- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 34 +- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 9 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 1 - openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 9 +- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 3 +- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h | 1 - openair1/PHY/TOOLS/time_meas.c | 133 ++- openair1/PHY/TOOLS/time_meas.h | 86 +- openair1/PHY/defs_RU.h | 1 + openair1/PHY/defs_gNB.h | 61 +- openair1/PHY/impl_defs_top.h | 11 +- openair1/SCHED/nfapi_lte_dummy.c | 11 +- openair1/SCHED/nfapi_nr_dummy.c | 9 +- openair1/SCHED_NR/fapi_nr_l1.c | 96 +-- openair1/SCHED_NR/fapi_nr_l1.h | 8 +- openair1/SCHED_NR/nr_prach_procedures.c | 55 +- openair1/SCHED_NR/nr_ru_procedures.c | 9 +- openair1/SCHED_NR/phy_frame_config_nr.c | 16 + openair1/SCHED_NR/phy_frame_config_nr.h | 2 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 299 ++++--- openair1/SCHED_NR/sched_nr.h | 2 +- openair1/SCHED_NR_UE/defs.h | 2 - openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 142 +--- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 293 +------ openair1/SCHED_NR_UE/pucch_uci_ue_nr.h | 27 - openair1/SIMULATION/LTE_PHY/dlsim.c | 10 +- openair1/SIMULATION/LTE_PHY/mbmssim.c | 10 +- openair1/SIMULATION/LTE_PHY/ulsim.c | 2 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 6 +- openair1/SIMULATION/NR_PHY/dlsim.c | 71 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 10 +- openair1/SIMULATION/NR_PHY/prachsim.c | 1 + openair1/SIMULATION/NR_PHY/pucchsim.c | 291 ++++--- openair1/SIMULATION/NR_PHY/ulsim.c | 239 ++++-- openair1/SIMULATION/TOOLS/abstraction.c | 13 +- openair1/SIMULATION/TOOLS/random_channel.c | 19 +- openair1/SIMULATION/TOOLS/sim.h | 4 +- openair2/COMMON/f1ap_messages_types.h | 2 +- openair2/COMMON/gtpv1_u_messages_def.h | 3 +- openair2/COMMON/gtpv1_u_messages_types.h | 20 +- openair2/COMMON/ngap_messages_types.h | 51 ++ openair2/COMMON/rrc_messages_types.h | 1 + openair2/ENB_APP/enb_config.c | 12 +- openair2/ENB_APP/enb_paramdef.h | 2 +- openair2/F1AP/dummy_enb.c | 13 + openair2/GNB_APP/MACRLC_nr_paramdef.h | 8 +- openair2/GNB_APP/gnb_config.c | 192 +++-- openair2/GNB_APP/gnb_paramdef.h | 26 +- .../NR_MAC_COMMON/nr_compute_tbs_common.c | 5 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 8 + openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 594 +++++-------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 20 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h | 3 + openair2/LAYER2/NR_MAC_UE/config_ue.c | 80 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 25 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 113 ++- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 5 +- openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c | 143 +--- .../nr_l1_helpers.h} | 24 +- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 157 +++- .../NR_MAC_UE/nr_ue_dci_configuration.c | 150 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 572 +++++++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 797 +++++++++++++++-- openair2/LAYER2/NR_MAC_gNB/config.c | 45 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 86 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 243 +++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 21 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 188 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 61 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 353 +++++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 232 +++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 213 +++-- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 28 +- openair2/LAYER2/NR_MAC_gNB/main.c | 82 ++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 15 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 26 +- openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 1 + openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c | 75 -- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 65 +- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 31 +- openair2/RRC/LTE/rrc_UE.c | 9 +- openair2/RRC/LTE/rrc_defs.h | 2 +- openair2/RRC/LTE/rrc_eNB.c | 8 - openair2/RRC/NR/L2_nr_interface.c | 8 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 288 ++++++- openair2/RRC/NR/MESSAGES/asn1_msg.h | 9 +- openair2/RRC/NR/nr_rrc_defs.h | 7 +- openair2/RRC/NR/rrc_gNB.c | 76 +- openair2/RRC/NR/rrc_gNB_NGAP.c | 151 ++-- openair2/RRC/NR/rrc_gNB_UE_context.c | 2 +- openair2/RRC/NR/rrc_gNB_nsa.c | 18 +- openair2/RRC/NR_UE/rrc_UE.c | 167 ++-- openair2/SDAP/nr_sdap/nr_sdap_gnb.c | 87 ++ openair2/SDAP/nr_sdap/nr_sdap_gnb.h | 61 ++ openair2/UTIL/OSA/osa_key_deriver.c | 2 + openair3/NAS/COMMON/API/NETWORK/as_message.c | 66 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 241 ++++-- openair3/NAS/NR_UE/nr_nas_msg_sim.h | 12 + openair3/NAS/UE/EMM/SAP/emm_as.c | 54 +- openair3/NAS/UE/nas_network.c | 26 +- openair3/NGAP/ngap_gNB_handlers.c | 7 +- openair3/ocp-gtpu/gtp_itf.cpp | 39 +- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 47 +- .../CONF/gnb.band257.tm1.32PRB.usrpn300.conf | 17 + .../CONF/gnb.band257.tm1.32PRB.usrpx300.conf | 17 + .../CONF/gnb.band257.tm1.66PRB.usrpn300.conf | 17 + .../CONF/gnb.band261.tm1.32PRB.usrpn300.conf | 17 + .../CONF/gnb.band66.tm1.106PRB.usrpn300.conf | 17 + .../CONF/gnb.band66.tm1.106PRB.usrpx300.conf | 17 + .../gnb.band78.106PRB.30kHz,usrpb2x0.conf | 17 + .../CONF/gnb.band78.106PRB.slave.conf | 17 + .../CONF/gnb.band78.slave.conf | 17 + .../gnb.band78.tm1.106PRB.PTRS.usrpx300.conf | 17 + .../CONF/gnb.band78.tm1.106PRB.usrpb210.conf | 17 + .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 17 + .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 17 + .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf | 17 + .../CONF/gnb.band78.tm1.217PRB.usrpx300.conf | 17 + .../CONF/gnb.band78.tm1.24PRB.usrpb210.conf | 17 + .../CONF/gnb.band78.tm1.24PRB.usrpn300.conf | 17 + .../CONF/gnb.band78.tm1.24PRB.usrpx300.conf | 17 + .../CONF/gnb.band78.tm1.273PRB.usrpn300.conf | 17 + .../GENERIC-LTE-EPC/CONF/testing_gnb.conf | 9 +- .../CONF/testing_gnb_24PRB.conf | 17 + .../CONF/testing_gnb_n310.conf | 17 + .../CONF/testing_gnb_nsa_n310.conf | 296 +++++++ .../PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf | 20 +- ...b.band78.tm1.106PRB.usrpn300.gtp-itti.conf | 17 + .../gnb.sa.band41.fr1.106PRB.usrpb210.conf | 26 +- .../gnb.sa.band78.fr1.106PRB.usrpb210.conf | 30 +- ...b.sa.band78.fr1.106PRB.usrpb210.sabox.conf | 17 + 257 files changed, 12071 insertions(+), 4910 deletions(-) create mode 100644 ci-scripts/Jenkinsfile-push-registry create mode 100644 ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf create mode 100644 ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf create mode 100644 ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf create mode 100644 ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf create mode 100755 ci-scripts/stats_monitor.py create mode 100755 ci-scripts/stats_monitor.py.old create mode 100644 ci-scripts/stats_monitor_conf.yaml create mode 100755 ci-scripts/stats_monitor_dev.py create mode 100644 ci-scripts/xml_files/fr1_enb_build.xml create mode 100644 ci-scripts/xml_files/fr1_lte_2x2_quectel.xml create mode 100644 ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml rename ci-scripts/yaml_files/{fr1_epc_tim => fr1_epc_20897}/docker-compose.yml (95%) rename ci-scripts/yaml_files/{fr1_epc_tim/docker-compose.yml.orig => magma_nsa_20897/docker-compose.yml} (62%) create mode 100755 ci-scripts/yaml_files/magma_nsa_20897/entrypoint.sh create mode 100644 ci-scripts/yaml_files/magma_nsa_20897/mme.conf create mode 100644 ci-scripts/yaml_files/magma_nsa_20897/mme_fd.sprint.conf create mode 100644 ci-scripts/yaml_files/magma_nsa_20897/redis_extern.conf create mode 100644 common/utils/telnetsrv/telnetsrv_5Gue_measurements.c create mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c create mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl delete mode 100644 openair1/PHY/NR_TRANSPORT/nr_dci_tools_common.c mode change 100755 => 100644 openair2/LAYER2/NR_MAC_UE/config_ue.c mode change 100755 => 100644 openair2/LAYER2/NR_MAC_UE/mac_defs.h mode change 100755 => 100644 openair2/LAYER2/NR_MAC_UE/mac_proto.h rename openair2/LAYER2/{nr_pdcp/nr_pdcp_entity_srb.h => NR_MAC_UE/nr_l1_helpers.h} (65%) mode change 100644 => 100755 delete mode 100644 openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c create mode 100644 openair2/SDAP/nr_sdap/nr_sdap_gnb.c create mode 100644 openair2/SDAP/nr_sdap/nr_sdap_gnb.h create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index f4b99e7f92..b413617580 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -220,6 +220,21 @@ pipeline { } } } + stage ("Images Push to Registries") { + when { expression {"PUSH".equals(env.gitlabActionType)} } + steps { + script { + triggerSlaveJob ('RAN-DockerHub-Push', 'Push-to-Docker-Hub') + } + post { + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } + } } post { always { @@ -247,6 +262,7 @@ pipeline { echo "This is a MERGE event" addGitLabMRComment comment: message } + echo "Pipeline is SUCCESSFUL" } } failure { @@ -256,6 +272,7 @@ pipeline { echo "This is a MERGE event" addGitLabMRComment comment: message } + echo "Pipeline FAILED" } } } diff --git a/ci-scripts/Jenkinsfile-push-registry b/ci-scripts/Jenkinsfile-push-registry new file mode 100644 index 0000000000..91d6136e0a --- /dev/null +++ b/ci-scripts/Jenkinsfile-push-registry @@ -0,0 +1,86 @@ +#!/bin/groovy +/* + * 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 + */ + +// Location of the python executor node shall be in the same subnet as the others servers +def nodeExecutor = params.nodeExecutor + +// Name of the phone resource +def ciServerResource = params.serverResource + +pipeline { + agent { + label nodeExecutor + } + options { + disableConcurrentBuilds() + ansiColor('xterm') + lock (ciServerResource) + } + stages { + stage ("Verify Parameters") { + steps { + script { + echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' + def allParametersPresent = true + + // It is already to late to check it + if (params.nodeExecutor != null) { + echo "Docker Push executor node : ${nodeExecutor}" + } + if (params.serverResource == null) { + allParametersPresent = false + } + } + } + } + stage ("Push to DockerHub") { + steps { + script { + WEEK_TAG = sh returnStdout: true, script: 'date +"%Y.w%U"' + WEEK_TAG = WEEK_TAG.trim() + + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.DH_Credentials}", usernameVariable: 'DH_Username', passwordVariable: 'DH_Password'] + ]) { + def listOfImages = ["oai-enb", "oai-gnb", "oai-lte-ue", "oai-nr-ue"] + sh "docker login -u ${DH_Username} -p ${DH_Password} > /dev/null 2>&1" + listOfImages.eachWithIndex { item, iindex -> + sh "docker image tag ${item}:develop ${DH_Username}/${item}:develop" + sh "docker image tag ${item}:develop ${DH_Username}/${item}:${WEEK_TAG}" + sh "docker push --quiet ${DH_Username}/${item}:${WEEK_TAG}" + sh "docker push --quiet ${DH_Username}/${item}:develop" + sh "docker rmi ${DH_Username}/${item}:${WEEK_TAG} ${DH_Username}/${item}:develop" + } + sh "docker logout > /dev/null 2>&1" + } + } + } + } + } + post { + always { + script { + echo "End of Registry Push" + } + } + } +} diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index 95aa4046d7..3243d1645d 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -265,6 +265,21 @@ pipeline { if(fileExists("enb.log.${env.BUILD_ID}.zip")) { archiveArtifacts "enb.log.${env.BUILD_ID}.zip" } + } + } + } + stage('Log Collection (CN)') { + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Transfer (CN)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/logs/oai-cn5g.log.zip ./oai-cn5g.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("oai-cn5g.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "oai-cn5g.log.${env.BUILD_ID}.zip" + } if(fileExists("ci-scripts/test_results.html")) { sh "mv ci-scripts/test_results.html test_results-${JOB_NAME}.html" sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: ${BUILD_ID}#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html" diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 2dcaf1a04f..40d74f4da0 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -47,30 +47,38 @@ pipeline { COMMIT_ID=sh returnStdout: true, script: """curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests/${MR}" | jq ".sha" || true """ COMMIT_ID=COMMIT_ID.trim() echo "Testing NSA on : ${MR} ${SRC_BRANCH} ${COMMIT_ID}" - //calling NSA sub job - build job: "RAN-NSA-Mini-Module", wait : true, propagate : false, parameters: [ + //calling NSA B200 + build job: "RAN-NSA-B200-Module-LTEBOX", wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) ] - //calling NSA long sub job -// build job: "RAN-NSA-Mini-Module-Long", wait : true, propagate : false, parameters: [ -// string(name: 'eNB_MR', value: String.valueOf(MR)), -// string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), -// string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), -// string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), -// booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) -// ] - //calling NSA attach/detach job -// build job: "RAN-NSA-Mini-Module-Attach-Detach", wait : true, propagate : false, parameters: [ -// string(name: 'eNB_MR', value: String.valueOf(MR)), -// string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), -// string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), -// string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), -// booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) -// ] + //calling NSA 2x2 + build job: "RAN-NSA-2x2-Module-OAIEPC", wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) + ] + //calling LTE 2x2 + build job: "RAN-LTE-2x2-Module-OAIEPC", wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) + ] + //calling SA + build job: "RAN-SA-Module-CN5G", wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) + ] } } diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml index 619e8fba15..51acb75968 100644 --- a/ci-scripts/ci_ueinfra.yaml +++ b/ci-scripts/ci_ueinfra.yaml @@ -4,7 +4,9 @@ idefix: Kind : quectel Process : Name : quectel-CM - Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4 + Cmd : /home/oaicicd/quectel-CM/quectel-CM -4 -s + Apn : + ltebox : oai.ipv4 WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach LogStore : /media/usb-drive/ci_qlogs @@ -14,22 +16,29 @@ idefix: HostUsername : oaicicd HostPassword : oaicicd HostSourceCodePath : none + MTU : 1500 nrmodule2_quectel: ID: nrmodule2_quectel State : enabled Kind : quectel Process : Name : quectel-CM - Cmd : /home/nrmodule2/quectel-CM/quectel-CM -s oai.ipv4 -4 + Cmd : /home/nrmodule2/quectel-CM/quectel-CM -4 -s + Apn : + OAICN5G : oai + OAI-Rel14-Docker : oai.ipv4 WakeupScript : ci_ctl_qtel.py /dev/ttyUSB7 wup DetachScript : ci_ctl_qtel.py /dev/ttyUSB7 detach LogStore : /media/ci_qlogs - PLMN : 20899 + PLMN : 20897 UENetwork : wwan1 HostIPAddress : 192.168.18.189 HostUsername : nrmodule2 HostPassword : linux HostSourceCodePath : none + StartCommands : + - sudo -S ip link set dev wwan1 mtu 1500 + MTU : 1500 dummy: ID: '' State : '' diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index ea09cd0585..ff2b261424 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -196,6 +196,7 @@ class Containerize(): # the potential merge. Note that merge conflicts should already been checked earlier imageTag = 'develop' sharedTag = 'develop' + forceSharedImageBuild = False if (self.ranAllowMerge): imageTag = 'ci-temp' if self.ranTargetBranch == '': @@ -204,6 +205,13 @@ class Containerize(): else: logging.debug('Merging with the target branch: ' + self.ranTargetBranch) mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + mySSH.command('git diff HEAD..origin/develop -- docker/Dockerfile.ran' + self.dockerfileprefix + ' | grep -i INDEX', '\$', 5) + result = re.search('index', mySSH.getBefore()) + if result is not None: + forceSharedImageBuild = True + sharedTag = 'ci-temp' + else: + forceSharedImageBuild = True # if asterix, copy the entitlement and subscription manager configurations if self.host == 'Red Hat': @@ -215,13 +223,14 @@ class Containerize(): sharedimage = 'ran-build' # Let's remove any previous run artifacts if still there mySSH.command(self.cli + ' image prune --force', '\$', 30) - if (not self.ranAllowMerge): - mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag, '\$', 30) + if forceSharedImageBuild: + mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag + ' || true', '\$', 30) for image,pattern in imageNames: - mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag, '\$', 30) + mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag + ' || true', '\$', 30) # Build the shared image only on Push Events (not on Merge Requests) - if (not self.ranAllowMerge): + # On when the shared image docker file is being modified. + if forceSharedImageBuild: mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) # First verify if the shared image was properly created. status = True diff --git a/ci-scripts/cls_module_ue.py b/ci-scripts/cls_module_ue.py index 96d4e0310e..74ae9c207e 100644 --- a/ci-scripts/cls_module_ue.py +++ b/ci-scripts/cls_module_ue.py @@ -61,7 +61,7 @@ class Module_UE: #this method checks if the specified Process is running on the server hosting the module #if not it will be started - def CheckCMProcess(self): + def CheckCMProcess(self,CNType): HOST=self.HostUsername+'@'+self.HostIPAddress COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep " logging.debug(COMMAND) @@ -76,7 +76,7 @@ class Module_UE: logging.debug('Starting ' + self.Process['Name']) mySSH = sshconnection.SSHConnection() mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) - mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S ' + self.Process['Cmd'] + ' &','\$',5) + mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S ' + self.Process['Cmd'] + ' ' + self.Process['Apn'][CNType] + ' &','\$',5) mySSH.close() #checking the process time.sleep(5) @@ -131,6 +131,33 @@ class Module_UE: logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m') return -1 + def CheckModuleMTU(self): + HOST=self.HostUsername+'@'+self.HostIPAddress + response= [] + tentative = 3 + while (len(response)==0) and (tentative>0): + COMMAND="ip a show dev " + self.UENetwork + " | grep mtu" + logging.debug(COMMAND) + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + response = ssh.stdout.readlines() + tentative-=1 + time.sleep(10) + if (tentative==0) and (len(response)==0): + logging.debug('\u001B[1;37;41m Module NIC MTU Not Found! Time expired \u001B[0m') + return -1 + else: #check response + result = re.search('mtu (?P[0-9]+)', response[0].decode("utf-8") ) + if result is not None: + if (result.group('mtu') is not None) and (str(result.group('mtu'))==str(self.MTU)) : + logging.debug('\u001B[1mUE Module NIC MTU is ' + str(self.MTU) + ' as expected\u001B[0m') + return 0 + else: + logging.debug('\u001B[1;37;41m Incorrect Module NIC MTU ' + str(result.group('mtu')) + '! Expected : ' + str(self.MTU) + '\u001B[0m') + return -1 + else: + logging.debug('\u001B[1;37;41m Module NIC MTU Not Found! \u001B[0m') + return -1 + def EnableTrace(self): if self.ue_trace=="yes": mySSH = sshconnection.SSHConnection() diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index f1ab8c106f..92a4e8637e 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -388,22 +388,45 @@ class OaiCiTest(): #RH Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE.ue_trace=ue_trace - is_module=Module_UE.CheckCMProcess() + is_module=Module_UE.CheckCMProcess(EPC.Type) if is_module: Module_UE.EnableTrace() time.sleep(5) - Module_UE.Command("wup") - logging.debug("Waiting for IP address to be assigned") - time.sleep(20) - logging.debug("Retrieve IP address") - status=Module_UE.GetModuleIPAddress() - if status==0: + + # Looping attach / detach / wait to be successful at least once + cnt = 0 + status = -1 + while cnt < 4: + Module_UE.Command("wup") + logging.debug("Waiting for IP address to be assigned") + time.sleep(20) + logging.debug("Retrieve IP address") + status=Module_UE.GetModuleIPAddress() + if status==0: + cnt = 10 + else: + cnt += 1 + Module_UE.Command("detach") + time.sleep(20) + + if cnt == 10 and status == 0: HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) + #execute additional commands from yaml file after UE attach + SSH = sshconnection.SSHConnection() + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + if hasattr(Module_UE,'StartCommands'): + for startcommand in Module_UE.StartCommands: + cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand + SSH.command(cmd,'\$',5) + SSH.close() + #check that the MTU is as expected / requested + Module_UE.CheckModuleMTU() else: #status==-1 failed to retrieve IP address HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return + def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,InfraUE): @@ -1033,14 +1056,34 @@ class OaiCiTest(): #Attention, as opposed to InitializeUE, the connect manager process is not checked as it is supposed to be active already #only 1- module wakeup, 2- check IP address Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) - Module_UE.Command("wup") - logging.debug("Waiting for IP address to be assigned") - time.sleep(20) - logging.debug("Retrieve IP address") - status=Module_UE.GetModuleIPAddress() - if status==0: + status = -1 + cnt = 0 + while cnt < 4: + Module_UE.Command("wup") + logging.debug("Waiting for IP address to be assigned") + time.sleep(20) + logging.debug("Retrieve IP address") + status=Module_UE.GetModuleIPAddress() + if status==0: + cnt = 10 + else: + cnt += 1 + Module_UE.Command("detach") + time.sleep(20) + + if cnt == 10 and status == 0: HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) + #execute additional commands from yaml file after UE attach + SSH = sshconnection.SSHConnection() + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + if hasattr(Module_UE,'StartCommands'): + for startcommand in Module_UE.StartCommands: + cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand + SSH.command(cmd,'\$',5) + SSH.close() + #check that the MTU is as expected / requested + Module_UE.CheckModuleMTU() else: #status==-1 failed to retrieve IP address HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) @@ -1539,6 +1582,8 @@ class OaiCiTest(): #target address is different depending on EPC type if re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE): Target = EPC.MmeIPAddress + elif re.match('OAICN5G', EPC.Type, re.IGNORECASE): + Target = '8.8.8.8' else: Target = EPC.IPAddress #ping from module NIC rather than IP address to make sure round trip is over the air @@ -1986,7 +2031,7 @@ class OaiCiTest(): if type==0: result = re.search('(?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)/ +(?P[0-9]+)', str(line)) else: - result = re.search('^\[ \d\].+ +(?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)\/(?P[0-9]+)', str(line)) + result = re.search('^\[\s+\d\].+ (?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)\/\s*(?P[0-9]+)', str(line)) if result is not None: bitrate = result.group('bitrate') @@ -2230,85 +2275,157 @@ class OaiCiTest(): def Iperf_Module(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC, Module_UE): - SSH = sshconnection.SSHConnection() - #RH temporary quick n dirty for test - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - cmd = 'echo ' + EPC.Password + ' | sudo -S ip link set dev tun5 mtu 1358' - SSH.command(cmd,'\$',5) - SSH.close() - - - #kill iperf processes before (in case there are still some remaining) - SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - cmd = 'killall --signal=SIGKILL iperf' - SSH.command(cmd,'\$',5) - SSH.close() - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - cmd = 'killall --signal=SIGKILL iperf' - SSH.command(cmd,'\$',5) - SSH.close() - - - iperf_time = self.Iperf_ComputeTime() - if self.iperf_direction=="DL": - logging.debug("Iperf for Module in DL mode detected") - #server side UE - SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup /opt/iperf-2.0.10/iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',5) - SSH.close() - #client side EPC + if (re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE)) or (re.match('OAICN5G', EPC.Type, re.IGNORECASE)): + #retrieve trf-gen container IP address + SSH = sshconnection.SSHConnection() SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',5) - cmd = 'iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',int(iperf_time)*5.0) + SSH.command('docker inspect --format="TRF_IP_ADDR = {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" prod-trf-gen', '\$', 5) + result = re.search('TRF_IP_ADDR = (?P[0-9\.]+)', SSH.getBefore()) + if result is not None: + trf_gen_IP = result.group('trf_ip_addr') SSH.close() - #copy the 2 resulting files locally - SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') - SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') - #send for analysis - filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) - - elif self.iperf_direction=="UL":#does not work at the moment - logging.debug("Iperf for Module in UL mode detected") - #server side EPC - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup iperf -s -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command(cmd,'\$',5) - SSH.close() - - #client side UE + #kill iperf processes on UE side before (in case there are still some remaining) SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'killall --signal=SIGKILL iperf' SSH.command(cmd,'\$',5) - SSH.command('/opt/iperf-2.0.10/iperf -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', int(iperf_time)*5.0) SSH.close() - #copy the 2 resulting files locally - SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') - SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') - #send for analysis - filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) - else : - logging.debug("Incorrect or missing IPERF direction in XML") + iperf_time = self.Iperf_ComputeTime() + if self.iperf_direction=="DL": + logging.debug("Iperf for Module in DL mode detected") + #server side UE + server_filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'rm ' + server_filename + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > ' + server_filename + ' &' + SSH.command(cmd,'\$',5) + SSH.close() + #client side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf"', '\$', 5) + iperf_cmd = 'bin/iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename + cmd = 'docker exec -it prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' + SSH.command(cmd,'\$',int(iperf_time)*5.0) + SSH.command('docker cp prod-trf-gen:/iperf-2.0.13/'+ client_filename + ' ' + EPC.SourceCodePath, '\$', 5) + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/' + client_filename, '.') + SSH.close() - #kill iperf processes after to be clean - SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - cmd = 'killall --signal=SIGKILL iperf' - SSH.command(cmd,'\$',5) - SSH.close() - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - cmd = 'killall --signal=SIGKILL iperf' - SSH.command(cmd,'\$',5) - SSH.close() - return + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, server_filename, '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, client_filename, '.') + #send for analysis + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,server_filename,1) + + elif self.iperf_direction=="UL": + logging.debug("Iperf for Module in UL mode detected") + #server side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf"', '\$', 5) + iperf_cmd = 'echo $USER; nohup bin/iperf -s -u 2>&1 > ' + server_filename + cmd = 'docker exec -it prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' + SSH.command(cmd,'\$',5) + SSH.close() + + #client side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'rm '+ client_filename + SSH.command(cmd,'\$',5) + SSH.command('iperf -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename, '\$', int(iperf_time)*5.0) + SSH.close() + + #once client is done, retrieve the server file from container to EPC Host + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + SSH.command('docker cp prod-trf-gen:/iperf-2.0.13/' + server_filename + ' ' + EPC.SourceCodePath, '\$', 5) + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/' + server_filename, '.') + SSH.close() + + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, client_filename, '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, server_filename, '.') + #send for analysis + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,server_filename,1) + else : + logging.debug("Incorrect or missing IPERF direction in XML") + + else: #default is ltebox + + SSH = sshconnection.SSHConnection() + + #kill iperf processes before (in case there are still some remaining) + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + SSH.close() + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + SSH.close() + + + iperf_time = self.Iperf_ComputeTime() + if self.iperf_direction=="DL": + logging.debug("Iperf for Module in DL mode detected") + #server side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup /opt/iperf-2.0.10/iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log &' + SSH.command(cmd,'\$',5) + SSH.close() + #client side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',int(iperf_time)*5.0) + SSH.close() + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + #send for analysis + filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) + + elif self.iperf_direction=="UL": + logging.debug("Iperf for Module in UL mode detected") + #server side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup iperf -s -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log &' + SSH.command(cmd,'\$',5) + SSH.close() + + #client side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + SSH.command('/opt/iperf-2.0.10/iperf -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', int(iperf_time)*5.0) + SSH.close() + + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + #send for analysis + filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) + else : + logging.debug("Incorrect or missing IPERF direction in XML") + + #kill iperf processes after to be clean + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + SSH.close() + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + SSH.close() + return def Iperf_common(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC): try: diff --git a/ci-scripts/conf_files/channelmod_rfsimu.conf b/ci-scripts/conf_files/channelmod_rfsimu.conf index 9a6ded24f1..cd4490d9ba 100644 --- a/ci-scripts/conf_files/channelmod_rfsimu.conf +++ b/ci-scripts/conf_files/channelmod_rfsimu.conf @@ -15,7 +15,7 @@ channelmod = { ds_tdl = 0; }, { - model_name = "rfsimu_channel_ue1" + model_name = "rfsimu_channel_ue0" type = "AWGN"; ploss_dB = 0; noise_power_dB = 0; diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf new file mode 100644 index 0000000000..d2e91fb872 --- /dev/null +++ b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf @@ -0,0 +1,281 @@ +Active_eNBs = ( "eNB-Eurecom-B38"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe02; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB-Eurecom-B38"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ( { mcc = 208; mnc = 97; mnc_length = 2; } ); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 1; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2605000000L; + nr_scg_ssb_freq = 624608; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 2; + nb_antennas_rx = 2; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -29; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + enable_measurement_reports = "no"; + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eno1"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "CI_ENB_IP_ADDR"; + ENB_INTERFACE_NAME_FOR_S1U = "eno1"; + ENB_IPV4_ADDRESS_FOR_S1U = "CI_ENB_IP_ADDR"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + ENB_IPV4_ADDRESS_FOR_X2C = "CI_ENB_IP_ADDR"; + ENB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + phy_test_mode = 0; + scheduler_mode = "fairRR"; + bler_target_upper = 20.0; + bler_target_lower = 10.0; + max_ul_rb_index = 27; + puSch10xSnr = 200; + puCch10xSnr = 150; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 200; + pucch1_dtx_threshold = 5 + pucch1ab_dtx_threshold =0; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [38]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + sdr_addrs = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2"; + + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +NETWORK_CONTROLLER : +{ + FLEXRAN_ENABLED = "no"; + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf index db0802fdd7..6c8d5ba6f0 100644 --- a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf +++ b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf @@ -6,7 +6,7 @@ eNBs = ( { ////////// Identification parameters: - eNB_ID = 0xe00; + eNB_ID = 0xe04; cell_type = "CELL_MACRO_ENB"; @@ -14,7 +14,7 @@ eNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ( { mcc = 208; mnc = 99; mnc_length = 2; } ); + plmn_list = ( { mcc = 208; mnc = 97; mnc_length = 2; } ); tr_s_preference = "local_mac" @@ -31,6 +31,7 @@ eNBs = prefix_type = "NORMAL"; eutra_band = 38; downlink_frequency = 2605000000L; + nr_scg_ssb_freq = 624608; uplink_frequency_offset = 0; Nid_cell = 0; N_RB_DL = 100; @@ -209,8 +210,8 @@ MACRLCs = ( scheduler_mode = "fairRR"; bler_target_upper = 20.0; bler_target_lower = 10.0; - max_ul_rb_index = 24; - puSch10xSnr = 100; + max_ul_rb_index = 27; + puSch10xSnr = 200; puCch10xSnr = 150; } ); diff --git a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf new file mode 100644 index 0000000000..9bf3136690 --- /dev/null +++ b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf @@ -0,0 +1,338 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_1 = 57; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 2; + initialULBWPmappingType_0 = 1 + # this is SS=2 L=13 + initialULBWPstartSymbolAndLength_0 = 41; + + initialULBWPk2_1 = 2; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=4 + initialULBWPstartSymbolAndLength_1 = 52; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.69.131"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.194/24"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.194/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 150; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 2; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + + sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf new file mode 100644 index 0000000000..dfbbdf659d --- /dev/null +++ b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf @@ -0,0 +1,334 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; +Num_Threads_PUSCH = 8; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 10; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + absoluteFrequencySSB = 620640; + # this is 3502.56 MHz + #absoluteFrequencySSB = 633504; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + dl_absoluteFrequencyPointA = 620112; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633504; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 133; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=133 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 36300; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 10; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_1 = 57; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 133; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 36300; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -108; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=2 L=13 + initialULBWPstartSymbolAndLength_0 = 41; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=4 + initialULBWPstartSymbolAndLength_1 = 52; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.69.131"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.194/24"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.194/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 150; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 2; + prach_dtx_threshold = 120; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + + sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index 8d403cf4ce..1c62882406 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -228,9 +228,8 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 1; pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 200; } ); @@ -270,6 +269,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf index 05c71c082e..850cf9a60c 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -259,6 +259,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf index 24dbdbd74b..a4452b202d 100644 --- a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf @@ -13,7 +13,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({mcc = 208; mnc = 99; mnc_length = 2;}); + plmn_list = ({mcc = 208; mnc = 97; mnc_length = 2;}); tr_s_preference = "local_mac" @@ -24,6 +24,7 @@ gNBs = pusch_AntennaPorts = 2; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; + ul_prbblacklist = "51,52,53,54" servingCellConfigCommon = ( { @@ -33,11 +34,11 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP) - absoluteFrequencySSB = 641272; //641032; #641968; 641968=start of ssb at 3600MHz + 82 RBs 641032=center of SSB at center of cell + # this is 3350.04 MHz + 53 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 624608; dl_frequencyBand = 78; - # this is 3600 MHz - dl_absoluteFrequencyPointA = 640000; + # this is 3350.04 MHz + dl_absoluteFrequencyPointA = 623336; #scs-SpecificCarrierList dl_offstToCarrier = 0; # subcarrierSpacing @@ -46,7 +47,7 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=84,L=13 (275*(L-1))+RBstart + # this is RBstart=43,L=24 (275*(L-1))+RBstart initialDLBWPlocationAndBandwidth = 6368; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 @@ -233,7 +234,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; - prach_dtx_threshold = 100; + prach_dtx_threshold = 120; } ); @@ -250,6 +251,7 @@ RUs = ( eNB_instances = [0]; bf_weights = [0x00007fff, 0x00007fff]; #clock_src = "external"; + sf_extension = 0 sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); @@ -268,12 +270,17 @@ security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen # valid values: nea0, nea1, nea2, nea3 - ciphering_algorithms = ( "nea0", "nea2" ); + ciphering_algorithms = ( "nea0" ); # preferred integrity algorithms # the first one of the list that an UE supports in chosen # valid values: nia0, nia1, nia2, nia3 - integrity_algorithms = ( "nia0" ); + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; }; log_config : diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf new file mode 100644 index 0000000000..c889ba2b89 --- /dev/null +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -0,0 +1,340 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 97; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + ul_prbblacklist = "51,52,53,54" + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_1 = 57; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=2 L=13 + initialULBWPstartSymbolAndLength_0 = 41; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=4 + initialULBWPstartSymbolAndLength_1 = 52; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; +# pusch_TargetSNRx10 = 200; +# pucch_TargetSNRx10 = 150; + ulsch_max_slots_inactivity=20; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 2; + prach_dtx_threshold = 120; +# pucch0_dtx_threshold = 150; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sf_extension = 0 + sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf index db190f177d..a5d35d450e 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -1,4 +1,4 @@ -Active_gNBs = ( "gNB-Eurecom-DU"); +Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; @@ -7,7 +7,7 @@ gNBs = { ////////// Identification parameters: gNB_ID = 0xe00; - gNB_name = "gNB-Eurecom-DU"; + gNB_name = "gNB-OAI"; // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; @@ -35,6 +35,7 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + ul_prbblacklist = "51,52,53,54" pdcch_ConfigSIB1 = ( { @@ -203,7 +204,7 @@ gNBs = }; - ////////// MME parameters: + ////////// AMF parameters: amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; active = "yes"; @@ -218,7 +219,7 @@ gNBs = GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; GNB_INTERFACE_NAME_FOR_NGU = "eth0"; GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; - GNB_PORT_FOR_S1U = 2152; # Spec 2152 + GNB_PORT_FOR_NGU = 2152; # Spec 2152 }; } @@ -229,18 +230,19 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 100; pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 150; } ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + } ); RUs = ( @@ -250,9 +252,9 @@ RUs = ( nb_rx = 1 att_tx = 0 att_rx = 0; - bands = [7]; + bands = [78]; max_pdschReferenceSignalPower = -27; - max_rxgain = 81; + max_rxgain = 75; eNB_instances = [0]; #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; @@ -279,6 +281,23 @@ rfsimulator : IQfile = "/tmp/rfsimulator.iqs"; }; +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 8d32e8b792..4f0f7c6b2e 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -211,7 +211,6 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 1; } ); @@ -257,6 +256,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index df2fd874ca..7bda7f7eb5 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -262,6 +262,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf index b981b27f53..e6bbbf2d41 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf @@ -272,6 +272,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/ci-scripts/datalog_rt_stats.yaml b/ci-scripts/datalog_rt_stats.yaml index 548caa0bdd..507ea5d182 100644 --- a/ci-scripts/datalog_rt_stats.yaml +++ b/ci-scripts/datalog_rt_stats.yaml @@ -12,7 +12,8 @@ Ref : feptx_prec : 8.0 feptx_ofdm : 50.0 feptx_total : 75.0 - L1 Tx processing : 300.0 + L1 Tx processing thread 0 : 300.0 + L1 Tx processing thread 1 : 300.0 DLSCH encoding : 230.0 L1 Rx processing : 175.0 PUSCH inner-receiver : 100.0 @@ -24,7 +25,8 @@ Threshold : feptx_prec : 1.25 feptx_ofdm : 1.25 feptx_total : 1.25 - L1 Tx processing : 1.25 + L1 Tx processing thread 0 : 1.25 + L1 Tx processing thread 1 : 1.25 DLSCH encoding : 1.25 L1 Rx processing : 1.25 PUSCH inner-receiver : 1.25 diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index 1c202438d2..8376e07fd5 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -66,6 +66,7 @@ class EPCManagement(): self.containerPrefix = 'prod' self.mmeConfFile = 'mme.conf' self.yamlPath = '' + self.isMagmaUsed = False #----------------------------------------------------------- @@ -164,7 +165,15 @@ class EPCManagement(): if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE): mySSH = SSH.SSHConnection() mySSH.open(self.IPAddress, self.UserName, self.Password) - mySSH.command('docker inspect --format="MME_IP_ADDR = {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" ' + self.containerPrefix + '-oai-mme', '\$', 5) + self.isMagmaUsed = False + mySSH.command('docker ps -a', '\$', 5) + result = re.search('magma', mySSH.getBefore()) + if result is not None: + self.isMagmaUsed = True + if self.isMagmaUsed: + mySSH.command('docker inspect --format="MME_IP_ADDR = {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" ' + self.containerPrefix + '-magma-mme', '\$', 5) + else: + mySSH.command('docker inspect --format="MME_IP_ADDR = {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" ' + self.containerPrefix + '-oai-mme', '\$', 5) result = re.search('MME_IP_ADDR = (?P[0-9\.]+)', mySSH.getBefore()) if result is not None: self.MmeIPAddress = result.group('mme_ip_addr') @@ -220,7 +229,7 @@ class EPCManagement(): mySSH = SSH.SSHConnection() mySSH.open(self.IPAddress, self.UserName, self.Password) if re.match('ltebox', self.Type, re.IGNORECASE): - logging.debug('Using the sabox simulated HSS') + logging.debug('Using the SABOX simulated HSS') mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5) mySSH.command('cd /opt/hss_sim0609', '\$', 5) @@ -229,6 +238,12 @@ class EPCManagement(): logging.debug('Using the sabox') mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./start_sabox', '\$', 5) + elif re.match('OAICN5G', self.Type, re.IGNORECASE): + logging.debug('Starting OAI CN5G') + mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) + mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5) + mySSH.command('cd /opt/oai-cn5g-fed/docker-compose', '\$', 5) + mySSH.command('./core-network.sh start nrf spgwu', '\$', 60) else: logging.error('This option should not occur!') mySSH.close() @@ -242,6 +257,16 @@ class EPCManagement(): return if re.match('ltebox', self.Type, re.IGNORECASE): self.MmeIPAddress = self.IPAddress + elif re.match('OAICN5G', self.Type, re.IGNORECASE): + mySSH = SSH.SSHConnection() + mySSH.open(self.IPAddress, self.UserName, self.Password) + response=mySSH.command3('docker container ls -f name=oai-amf', 10) + if len(response)>1: + response=mySSH.command3('docker inspect --format=\'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\' oai-amf', 10) + tmp = str(response[0],'utf-8') + self.MmeIPAddress = tmp.rstrip() + logging.debug('AMF IP Address ' + self.MmeIPAddress) + mySSH.close() def CheckHSSProcess(self, status_queue): try: @@ -273,7 +298,15 @@ class EPCManagement(): mySSH = SSH.SSHConnection() mySSH.open(self.IPAddress, self.UserName, self.Password) if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE): - mySSH.command('docker top ' + self.containerPrefix + '-oai-mme', '\$', 5) + self.isMagmaUsed = False + mySSH.command('docker ps -a', '\$', 5) + result = re.search('magma', mySSH.getBefore()) + if result is not None: + self.isMagmaUsed = True + if self.isMagmaUsed: + mySSH.command('docker top ' + self.containerPrefix + '-magma-mme', '\$', 5) + else: + mySSH.command('docker top ' + self.containerPrefix + '-oai-mme', '\$', 5) else: mySSH.command('stdbuf -o0 ps -aux | grep --color=never mme | grep -v grep', '\$', 5) if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE): @@ -433,6 +466,7 @@ class EPCManagement(): mySSH = SSH.SSHConnection() mySSH.open(self.IPAddress, self.UserName, self.Password) if re.match('ltebox', self.Type, re.IGNORECASE): + logging.debug('Terminating SA BOX') mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./stop_sabox', '\$', 5) time.sleep(1) @@ -440,6 +474,12 @@ class EPCManagement(): mySSH.command('cd scripts', '\$', 5) time.sleep(1) mySSH.command('echo ' + self.Password + ' | sudo -S screen -S simulated_5g_hss -X quit', '\$', 5) + elif re.match('OAICN5G', self.Type, re.IGNORECASE): + self.LogCollectOAICN5G() + logging.debug('Terminating OAI CN5G') + mySSH.command('cd /opt/oai-cn5g-fed/docker-compose', '\$', 5) + mySSH.command('docker-compose down', '\$', 5) + mySSH.command('./core-network.sh stop nrf spgwu', '\$', 60) else: logging.error('This should not happen!') mySSH.close() @@ -466,6 +506,12 @@ class EPCManagement(): HTML.CreateHtmlTabFooter(False) sys.exit('docker-compose not installed on ' + self.IPAddress) + # Checking if it is a MAGMA deployment + self.isMagmaUsed = False + if os.path.isfile('./' + self.yamlPath + '/redis_extern.conf'): + self.isMagmaUsed = True + logging.debug('MAGMA MME is used!') + mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) mySSH.command('if [ -d ' + self.SourceCodePath + '/logs ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/logs ; fi', '\$', 5) mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts ' + self.SourceCodePath + '/logs', '\$', 5) @@ -477,10 +523,15 @@ class EPCManagement(): # - docker-compose config | grep container_name mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5) mySSH.copyout(self.IPAddress, self.UserName, self.Password, './' + self.yamlPath + '/docker-compose.yml', self.SourceCodePath + '/scripts') + if self.isMagmaUsed: + mySSH.copyout(self.IPAddress, self.UserName, self.Password, './' + self.yamlPath + '/entrypoint.sh', self.SourceCodePath + '/scripts') + mySSH.copyout(self.IPAddress, self.UserName, self.Password, './' + self.yamlPath + '/mme.conf', self.SourceCodePath + '/scripts') + mySSH.copyout(self.IPAddress, self.UserName, self.Password, './' + self.yamlPath + '/mme_fd.sprint.conf', self.SourceCodePath + '/scripts') + mySSH.copyout(self.IPAddress, self.UserName, self.Password, './' + self.yamlPath + '/redis_extern.conf', self.SourceCodePath + '/scripts') + mySSH.command('chmod a+x ' + self.SourceCodePath + '/scripts/entrypoint.sh', '\$', 5) mySSH.command('wget --quiet --tries=3 --retry-connrefused https://raw.githubusercontent.com/OPENAIRINTERFACE/openair-hss/develop/src/hss_rel14/db/oai_db.cql', '\$', 30) mySSH.command('docker-compose down', '\$', 60) mySSH.command('docker-compose up -d db_init', '\$', 60) - # databases take time... time.sleep(10) cnt = 0 @@ -502,8 +553,12 @@ class EPCManagement(): # deploying EPC cNFs mySSH.command('docker-compose up -d oai_spgwu', '\$', 60) - listOfContainers = 'prod-cassandra prod-oai-hss prod-oai-mme prod-oai-spgwc prod-oai-spgwu-tiny' - expectedHealthyContainers = 5 + if self.isMagmaUsed: + listOfContainers = 'prod-cassandra prod-oai-hss prod-magma-mme prod-oai-spgwc prod-oai-spgwu-tiny prod-redis' + expectedHealthyContainers = 6 + else: + listOfContainers = 'prod-cassandra prod-oai-hss prod-oai-mme prod-oai-spgwc prod-oai-spgwu-tiny' + expectedHealthyContainers = 5 # Checking for additional services mySSH.command('docker-compose config', '\$', 5) @@ -534,7 +589,10 @@ class EPCManagement(): logging.debug(' -- ' + str(startingNb) + ' still starting container(s)') if healthyNb == expectedHealthyContainers: mySSH.command('docker exec -d prod-oai-hss /bin/bash -c "nohup tshark -i any -f \'port 9042 or port 3868\' -w /tmp/hss_check_run.pcap 2>&1 > /dev/null"', '\$', 5) - mySSH.command('docker exec -d prod-oai-mme /bin/bash -c "nohup tshark -i any -f \'port 3868 or port 2123 or port 36412\' -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"', '\$', 10) + if self.isMagmaUsed: + mySSH.command('docker exec -d prod-magma-mme /bin/bash -c "nohup tshark -i any -f \'port 3868 or port 2123 or port 36412\' -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"', '\$', 10) + else: + mySSH.command('docker exec -d prod-oai-mme /bin/bash -c "nohup tshark -i any -f \'port 3868 or port 2123 or port 36412\' -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"', '\$', 10) mySSH.command('docker exec -d prod-oai-spgwc /bin/bash -c "nohup tshark -i any -f \'port 2123 or port 8805\' -w /tmp/spgwc_check_run.pcap 2>&1 > /dev/null"', '\$', 10) # on SPGW-U, not capturing on SGI to avoid huge file mySSH.command('docker exec -d prod-oai-spgwu-tiny /bin/bash -c "nohup tshark -i any -f \'port 8805\' -w /tmp/spgwu_check_run.pcap 2>&1 > /dev/null"', '\$', 10) @@ -552,24 +610,45 @@ class EPCManagement(): mySSH = SSH.SSHConnection() mySSH.open(self.IPAddress, self.UserName, self.Password) + # Checking if it is a MAGMA deployment. + mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5) + mySSH.command('docker-compose ps -a', '\$', 5) + self.isMagmaUsed = False + result = re.search('magma', mySSH.getBefore()) + if result is not None: + self.isMagmaUsed = True + logging.debug('MAGMA MME is used!') # Recovering logs and pcap files mySSH.command('cd ' + self.SourceCodePath + '/logs', '\$', 5) mySSH.command('docker exec -it prod-oai-hss /bin/bash -c "killall --signal SIGINT oai_hss tshark"', '\$', 5) - mySSH.command('docker exec -it prod-oai-mme /bin/bash -c "killall --signal SIGINT tshark"', '\$', 5) + if self.isMagmaUsed: + mySSH.command('docker exec -it prod-magma-mme /bin/bash -c "killall --signal SIGINT tshark"', '\$', 5) + else: + mySSH.command('docker exec -it prod-oai-mme /bin/bash -c "killall --signal SIGINT tshark"', '\$', 5) mySSH.command('docker exec -it prod-oai-spgwc /bin/bash -c "killall --signal SIGINT oai_spgwc tshark"', '\$', 5) mySSH.command('docker exec -it prod-oai-spgwu-tiny /bin/bash -c "killall --signal SIGINT tshark"', '\$', 5) mySSH.command('docker logs prod-oai-hss > hss_' + self.testCase_id + '.log', '\$', 5) - mySSH.command('docker logs prod-oai-mme > mme_' + self.testCase_id + '.log', '\$', 5) + if self.isMagmaUsed: + mySSH.command('docker cp --follow-link prod-magma-mme:/var/log/mme.log mme_' + self.testCase_id + '.log', '\$', 15) + else: + mySSH.command('docker logs prod-oai-mme > mme_' + self.testCase_id + '.log', '\$', 5) mySSH.command('docker logs prod-oai-spgwc > spgwc_' + self.testCase_id + '.log', '\$', 5) mySSH.command('docker logs prod-oai-spgwu-tiny > spgwu_' + self.testCase_id + '.log', '\$', 5) mySSH.command('docker cp prod-oai-hss:/tmp/hss_check_run.pcap hss_' + self.testCase_id + '.pcap', '\$', 60) - mySSH.command('docker cp prod-oai-mme:/tmp/mme_check_run.pcap mme_' + self.testCase_id + '.pcap', '\$', 60) + if self.isMagmaUsed: + mySSH.command('docker cp prod-magma-mme:/tmp/mme_check_run.pcap mme_' + self.testCase_id + '.pcap', '\$', 60) + else: + mySSH.command('docker cp prod-oai-mme:/tmp/mme_check_run.pcap mme_' + self.testCase_id + '.pcap', '\$', 60) mySSH.command('docker cp prod-oai-spgwc:/tmp/spgwc_check_run.pcap spgwc_' + self.testCase_id + '.pcap', '\$', 60) mySSH.command('docker cp prod-oai-spgwu-tiny:/tmp/spgwu_check_run.pcap spgwu_' + self.testCase_id + '.pcap', '\$', 60) # Remove all mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5) - listOfContainers = 'prod-cassandra prod-oai-hss prod-oai-mme prod-oai-spgwc prod-oai-spgwu-tiny' - nbContainers = 5 + if self.isMagmaUsed: + listOfContainers = 'prod-cassandra prod-oai-hss prod-magma-mme prod-oai-spgwc prod-oai-spgwu-tiny prod-redis' + nbContainers = 6 + else: + listOfContainers = 'prod-cassandra prod-oai-hss prod-oai-mme prod-oai-spgwc prod-oai-spgwu-tiny' + nbContainers = 5 # Checking for additional services mySSH.command('docker-compose config', '\$', 5) configResponse = mySSH.getBefore() @@ -679,3 +758,16 @@ class EPCManagement(): logging.error('This option should not occur!') mySSH.close() + def LogCollectOAICN5G(self): + mySSH = SSH.SSHConnection() + mySSH.open(self.IPAddress, self.UserName, self.Password) + logging.debug('OAI CN5G Collecting Log files to workspace') + mySSH.command('echo ' + self.Password + ' | sudo rm -rf ' + self.SourceCodePath + '/logs', '\$', 5) + mySSH.command('mkdir ' + self.SourceCodePath + '/logs','\$', 5) + containers_list=['oai-smf','oai-spgwu','oai-amf','oai-nrf'] + for c in containers_list: + mySSH.command('docker logs ' + c + ' > ' + self.SourceCodePath + '/logs/' + c + '.log', '\$', 5) + mySSH.command('cd ' + self.SourceCodePath + '/logs', '\$', 5) + mySSH.command('zip oai-cn5g.log.zip *.log', '\$', 60) + mySSH.close() + diff --git a/ci-scripts/main.py b/ci-scripts/main.py index d66c0c6305..9923d515a4 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -154,6 +154,7 @@ def GetParametersFromXML(action): elif action == 'Initialize_eNB': RAN.eNB_Trace=test.findtext('eNB_Trace') + RAN.eNB_Stats=test.findtext('eNB_Stats') RAN.Initialize_eNB_args=test.findtext('Initialize_eNB_args') eNB_instance=test.findtext('eNB_instance') USRPIPAddress=test.findtext('USRP_IPAddress') diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 5e3d8e388f..9acb1de34e 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -39,7 +39,6 @@ import time from multiprocessing import Process, Lock, SimpleQueue import yaml - #----------------------------------------------------------- # OAI Testing modules #----------------------------------------------------------- @@ -94,6 +93,7 @@ class RANManagement(): self.runtime_stats= '' self.datalog_rt_stats={} self.eNB_Trace = '' #if 'yes', Tshark will be launched at initialization + self.eNB_Stats = '' #if 'yes', Statistics Monitor will be launched at initialization self.USRPIPAddress = '' @@ -341,6 +341,8 @@ class RANManagement(): self.testCase_id = HTML.testCase_id mySSH = SSH.SSHConnection() + cwd = os.getcwd() + mySSH.copyout(lIpAddr,lUserName,lPassWord, cwd + "/active_net_interfaces.awk", "/tmp") #reboot USRP if requested in xml if self.USRPIPAddress!='': @@ -461,10 +463,36 @@ class RANManagement(): mySSH.command('if [ -e rbconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm rbconfig.raw; fi', '\$', 5) mySSH.command('if [ -e reconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm reconfig.raw; fi', '\$', 5) # NOTE: WE SHALL do a check if the executable is present (in case build went wrong) - mySSH.command('echo "ulimit -c unlimited && ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) + + #hack UHD_RFNOC_DIR variable for gNB / N310 on RHEL8 server: + #if the USRP address is in the xml then we are using an eth USRP (N3xx) + if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): + gNB = False + else: + gNB = True + if ((self.USRPIPAddress!='') and (gNB==True)): + mySSH.command('echo ' + lPassWord + ' | echo "ulimit -c unlimited && sudo UHD_RFNOC_DIR=/usr/local/share/uhd/rfnoc ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) + #otherwise the regular command is ok + else: + mySSH.command('echo "ulimit -c unlimited && ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) + mySSH.command('chmod 775 ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf enb_' + self.testCase_id + '.log', '\$', 5) mySSH.command('echo $USER; nohup sudo -E ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh > ' + lSourcePath + '/cmake_targets/enb_' + self.testCase_id + '.log 2>&1 &', lUserName, 10) + + + #stats monitoring during runtime + time.sleep(20) + monitor_file='../ci-scripts/stats_monitor.py' + conf_file='../ci-scripts/stats_monitor_conf.yaml' + if self.eNB_Stats=='yes': + if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): + mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' enb 2>&1 > enb_stats_monitor_execution.log &', '\$', 5) + else: + mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' gnb 2>&1 > gnb_stats_monitor_execution.log &', '\$', 5) + + + self.eNBLogFiles[int(self.eNB_instance)] = 'enb_' + self.testCase_id + '.log' if extra_options != '': self.eNBOptions[int(self.eNB_instance)] = extra_options @@ -539,6 +567,8 @@ class RANManagement(): self.eNBstatuses[int(self.eNB_instance)] = int(self.eNB_serverId[self.eNB_instance]) mySSH.close() + + HTML.CreateHtmlTestRow(self.air_interface[self.eNB_instance] + ' -O ' + config_file + extra_options, 'OK', CONST.ALL_PROCESSES_OK) logging.debug('\u001B[1m Initialize eNB/gNB/ocp-eNB Completed\u001B[0m') @@ -657,6 +687,11 @@ class RANManagement(): fileToAnalyze = self.eNBLogFiles[int(self.eNB_instance)] self.eNBLogFiles[int(self.eNB_instance)] = '' if analyzeFile: + #*stats.log files + pickle + png + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/*stats.log', '.') + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/*.pickle', '.') + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/*.png', '.') + # copyin_res = mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/' + fileToAnalyze, '.') if (copyin_res == -1): logging.debug('\u001B[1;37;41m Could not copy ' + nodeB_prefix + 'NB logfile to analyze it! \u001B[0m') @@ -665,12 +700,20 @@ class RANManagement(): self.eNBmbmsEnables[int(self.eNB_instance)] = False return if self.eNB_serverId[self.eNB_instance] != '0': + #*stats.log files + pickle + png + + #debug / tentative + mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './nrL1_stats.log', self.eNBSourceCodePath + '/cmake_targets/') + mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './nrMAC_stats.log', self.eNBSourceCodePath + '/cmake_targets/') + mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './gnb_stats_monitor.pickle', self.eNBSourceCodePath + '/cmake_targets/') + mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './gnb_stats_monitor.png', self.eNBSourceCodePath + '/cmake_targets/') + # mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './' + fileToAnalyze, self.eNBSourceCodePath + '/cmake_targets/') logging.debug('\u001B[1m Analyzing ' + nodeB_prefix + 'NB logfile \u001B[0m ' + fileToAnalyze) logStatus = self.AnalyzeLogFile_eNB(fileToAnalyze, HTML) if (logStatus < 0): HTML.CreateHtmlTestRow('N/A', 'KO', logStatus) - self.preamtureExit = True + self.prematureExit = True self.eNBmbmsEnables[int(self.eNB_instance)] = False return else: @@ -691,8 +734,8 @@ class RANManagement(): mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/enb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/gnb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm -f enb.log.zip', '\$', 5) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log', '\$', 60) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log', '\$', 5) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor.png', '\$', 60) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *.pickle *.png', '\$', 5) mySSH.close() def AnalyzeLogFile_eNB(self, eNBlogFile, HTML): @@ -1032,7 +1075,7 @@ class RANManagement(): for k in datalog_rt_stats['Data']: if float(datalog_rt_stats['Data'][k][2])> datalog_rt_stats['Threshold'][k]: #condition for fail : avg/ref is greater than the fixed threshold #setting prematureExit is ok although not the best option - self.prematureExit=True + self.prematureExit=False #temp for debug : do not stop the test if RT stats are excedeed else: statMsg = 'No real time stats found in the log file\n' logging.debug('No real time stats found in the log file') diff --git a/ci-scripts/sshconnection.py b/ci-scripts/sshconnection.py index b4087c9695..b85c40a0be 100644 --- a/ci-scripts/sshconnection.py +++ b/ci-scripts/sshconnection.py @@ -163,6 +163,18 @@ class SSHConnection(): lSsh = subprocess.Popen(["ssh", "%s" % myHost, commandline],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) self.cmd2Results = str(lSsh.stdout.readlines()) + def command3(self, commandline, timeout, silent=False): + if not silent: + logging.debug(commandline) + self.cmd2Results = '' + myHost = self.username + '@' + self.ipaddress + # CAUTION: THIS METHOD IMPLIES THAT THERE ARE VALID SSH KEYS + # BETWEEN THE PYTHON EXECUTOR NODE AND THE REMOTE HOST + # OTHERWISE IT WON'T WORK + lSsh = subprocess.Popen(["ssh", "%s" % myHost, commandline],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + return lSsh.stdout.readlines() + + def close(self): self.ssh.timeout = 5 self.ssh.sendline('exit') diff --git a/ci-scripts/stats_monitor.py b/ci-scripts/stats_monitor.py new file mode 100755 index 0000000000..877194de59 --- /dev/null +++ b/ci-scripts/stats_monitor.py @@ -0,0 +1,102 @@ +""" +To create graphs and pickle from runtime statistics in L1,MAC,RRC,PDCP files +""" + +import subprocess +import time +import shlex +import re +import sys +import pickle +import matplotlib.pyplot as plt +import numpy as np +import yaml + + +class StatMonitor(): + def __init__(self,cfg_file): + with open(cfg_file,'r') as file: + self.d = yaml.load(file) + for node in self.d: + for metric in self.d[node]: + self.d[node][metric]=[] + + + def process_gnb (self,node_type,output): + for line in output: + tmp=line.decode("utf-8") + result=re.match(r'^.*\bdlsch_rounds\b ([0-9]+)\/([0-9]+).*\bdlsch_errors\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['dlsch_err'].append(int(result.group(3))) + percentage=float(result.group(2))/float(result.group(1)) + self.d[node_type]['dlsch_err_perc_round_1'].append(percentage) + result=re.match(r'^.*\bulsch_rounds\b ([0-9]+)\/([0-9]+).*\bulsch_errors\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['ulsch_err'].append(int(result.group(3))) + percentage=float(result.group(2))/float(result.group(1)) + self.d[node_type]['ulsch_err_perc_round_1'].append(percentage) + + + def process_enb (self,node_type,output): + for line in output: + tmp=line.decode("utf-8") + result=re.match(r'^.*\bPHR\b ([0-9]+).+\bbler\b ([0-9]+\.[0-9]+).+\bmcsoff\b ([0-9]+).+\bmcs\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['PHR'].append(int(result.group(1))) + self.d[node_type]['bler'].append(float(result.group(2))) + self.d[node_type]['mcsoff'].append(int(result.group(3))) + self.d[node_type]['mcs'].append(int(result.group(4))) + + + def collect(self,node_type): + if node_type=='enb': + cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' + else: #'gnb' + cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' + process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + output = process.stdout.readlines() + if node_type=='enb': + self.process_enb(node_type,output) + else: #'gnb' + self.process_gnb(node_type,output) + + + def graph(self,node_type): + col = 1 + figure, axis = plt.subplots(len(self.d[node_type]), col ,figsize=(10, 10)) + i=0 + for metric in self.d[node_type]: + major_ticks = np.arange(0, len(self.d[node_type][metric])+1, 1) + axis[i].set_xticks(major_ticks) + axis[i].set_xticklabels([]) + axis[i].plot(self.d[node_type][metric],marker='o') + axis[i].set_xlabel('time') + axis[i].set_ylabel(metric) + axis[i].set_title(metric) + i+=1 + + plt.tight_layout() + # Combine all the operations and display + plt.savefig(node_type+'_stats_monitor.png') + plt.show() + + +if __name__ == "__main__": + + cfg_filename = sys.argv[1] #yaml file as metrics config + node = sys.argv[2]#enb or gnb + mon=StatMonitor(cfg_filename) + + #collecting stats when modem process is stopped + CMD='ps aux | grep mode | grep -v grep' + process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + while len(output)!=0 : + mon.collect(node) + process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + time.sleep(1) + print('Process stopped') + with open(node+'_stats_monitor.pickle', 'wb') as handle: + pickle.dump(mon.d, handle, protocol=pickle.HIGHEST_PROTOCOL) + mon.graph(node) diff --git a/ci-scripts/stats_monitor.py.old b/ci-scripts/stats_monitor.py.old new file mode 100755 index 0000000000..ae9b39bfa6 --- /dev/null +++ b/ci-scripts/stats_monitor.py.old @@ -0,0 +1,94 @@ +import subprocess +import time +import shlex +import re +import sys +import matplotlib.pyplot as plt +import pickle +import numpy as np +import os + +def collect(d, node_type): + if node_type=='enb': + cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' + else: #'gnb' + cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' + process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + output = process.stdout.readlines() + for l in output: + tmp=l.decode("utf-8") + result=re.match(rf'^.*\bPHR\b ([0-9]+).+\bbler\b ([0-9]+\.[0-9]+).+\bmcsoff\b ([0-9]+).+\bmcs\b ([0-9]+)',tmp) + if result is not None: + d['PHR'].append(int(result.group(1))) + d['bler'].append(float(result.group(2))) + d['mcsoff'].append(int(result.group(3))) + d['mcs'].append(int(result.group(4))) + + +def graph(d, node_type): + + + figure, axis = plt.subplots(4, 1,figsize=(10, 10)) + + major_ticks = np.arange(0, len(d['PHR'])+1, 1) + axis[0].set_xticks(major_ticks) + axis[0].set_xticklabels([]) + axis[0].plot(d['PHR'],marker='o') + axis[0].set_xlabel('time') + axis[0].set_ylabel('PHR') + axis[0].set_title("PHR") + + major_ticks = np.arange(0, len(d['bler'])+1, 1) + axis[1].set_xticks(major_ticks) + axis[1].set_xticklabels([]) + axis[1].plot(d['bler'],marker='o') + axis[1].set_xlabel('time') + axis[1].set_ylabel('bler') + axis[1].set_title("bler") + + major_ticks = np.arange(0, len(d['mcsoff'])+1, 1) + axis[2].set_xticks(major_ticks) + axis[2].set_xticklabels([]) + axis[2].plot(d['mcsoff'],marker='o') + axis[2].set_xlabel('time') + axis[2].set_ylabel('mcsoff') + axis[2].set_title("mcsoff") + + major_ticks = np.arange(0, len(d['mcs'])+1, 1) + axis[3].set_xticks(major_ticks) + axis[3].set_xticklabels([]) + axis[3].plot(d['mcs'],marker='o') + axis[3].set_xlabel('time') + axis[3].set_ylabel('mcs') + axis[3].set_title("mcs") + + plt.tight_layout() + # Combine all the operations and display + plt.savefig(node_type+'_stats_monitor.png') + plt.show() + +if __name__ == "__main__": + + node_type = sys.argv[1]#enb or gnb + + d={} + d['PHR']=[] + d['bler']=[] + d['mcsoff']=[] + d['mcs']=[] + + + cmd='ps aux | grep modem | grep -v grep' + process=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + while len(output)!=0 : + collect(d, node_type) + process=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + time.sleep(1) + print('process stopped') + with open(node_type+'_stats_monitor.pickle', 'wb') as handle: + pickle.dump(d, handle, protocol=pickle.HIGHEST_PROTOCOL) + graph(d, node_type) + + diff --git a/ci-scripts/stats_monitor_conf.yaml b/ci-scripts/stats_monitor_conf.yaml new file mode 100644 index 0000000000..6c0a2b0225 --- /dev/null +++ b/ci-scripts/stats_monitor_conf.yaml @@ -0,0 +1,11 @@ +enb : + PHR: + bler: + mcsoff: + mcs: + +gnb : + dlsch_err: + dlsch_err_perc_round_1: + ulsch_err: + ulsch_err_perc_round_1: \ No newline at end of file diff --git a/ci-scripts/stats_monitor_dev.py b/ci-scripts/stats_monitor_dev.py new file mode 100755 index 0000000000..83de20f5d2 --- /dev/null +++ b/ci-scripts/stats_monitor_dev.py @@ -0,0 +1,101 @@ +""" +To create graphs and pickle from runtime statistics in L1,MAC,RRC,PDCP files +""" + +import subprocess +import time +import shlex +import re +import sys +import pickle +import matplotlib.pyplot as plt +import numpy as np +import yaml + + +class StatMonitor(): + def __init__(self,): + with open('stats_monitor_conf.yaml','r') as file: + self.d = yaml.load(file) + for node in self.d: + for metric in self.d[node]: + self.d[node][metric]=[] + + + def process_gnb (self,node_type,output): + for line in output: + tmp=line.decode("utf-8") + result=re.match(r'^.*\bdlsch_rounds\b ([0-9]+)\/([0-9]+).*\bdlsch_errors\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['dlsch_err'].append(int(result.group(3))) + percentage=float(result.group(2))/float(result.group(1)) + self.d[node_type]['dlsch_err_perc_round_1'].append(percentage) + result=re.match(r'^.*\bulsch_rounds\b ([0-9]+)\/([0-9]+).*\bulsch_errors\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['ulsch_err'].append(int(result.group(3))) + percentage=float(result.group(2))/float(result.group(1)) + self.d[node_type]['ulsch_err_perc_round_1'].append(percentage) + + + def process_enb (self,node_type,output): + for line in output: + tmp=line.decode("utf-8") + result=re.match(r'^.*\bPHR\b ([0-9]+).+\bbler\b ([0-9]+\.[0-9]+).+\bmcsoff\b ([0-9]+).+\bmcs\b ([0-9]+)',tmp) + if result is not None: + self.d[node_type]['PHR'].append(int(result.group(1))) + self.d[node_type]['bler'].append(float(result.group(2))) + self.d[node_type]['mcsoff'].append(int(result.group(3))) + self.d[node_type]['mcs'].append(int(result.group(4))) + + + def collect(self,node_type): + if node_type=='enb': + cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' + else: #'gnb' + cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' + process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + output = process.stdout.readlines() + if node_type=='enb': + self.process_enb(node_type,output) + else: #'gnb' + self.process_gnb(node_type,output) + + + def graph(self,node_type): + col = 1 + figure, axis = plt.subplots(len(self.d[node_type]), col ,figsize=(10, 10)) + i=0 + for metric in self.d[node_type]: + major_ticks = np.arange(0, len(self.d[node_type][metric])+1, 1) + axis[i].set_xticks(major_ticks) + axis[i].set_xticklabels([]) + axis[i].plot(self.d[node_type][metric],marker='o') + axis[i].set_xlabel('time') + axis[i].set_ylabel(metric) + axis[i].set_title(metric) + i+=1 + + plt.tight_layout() + # Combine all the operations and display + plt.savefig(node_type+'_stats_monitor.png') + plt.show() + + +if __name__ == "__main__": + + node = sys.argv[1]#enb or gnb + mon=StatMonitor() + + #collecting stats when modem process is stopped + CMD='ps aux | grep mode | grep -v grep' + process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + while len(output)!=0 : + mon.collect(node) + process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) + output = process.stdout.readlines() + time.sleep(1) + print('Process stopped') + with open(node+'_stats_monitor.pickle', 'wb') as handle: + pickle.dump(mon.d, handle, protocol=pickle.HIGHEST_PROTOCOL) + mon.graph(node) diff --git a/ci-scripts/xml_files/fr1_enb_build.xml b/ci-scripts/xml_files/fr1_enb_build.xml new file mode 100644 index 0000000000..084f58a591 --- /dev/null +++ b/ci-scripts/xml_files/fr1_enb_build.xml @@ -0,0 +1,50 @@ + + + build-tab + Build + wrench + + 000001 + 000002 + + + + + Build_eNB + Build eNB + -w USRP -c --eNB --ninja + 0 + 0 + True + True + + + + WaitEndBuild_eNB + Wait for end of Build eNB + 0 + 0 + + + diff --git a/ci-scripts/xml_files/fr1_gnb_build.xml b/ci-scripts/xml_files/fr1_gnb_build.xml index d0c91f407d..43cff75620 100644 --- a/ci-scripts/xml_files/fr1_gnb_build.xml +++ b/ci-scripts/xml_files/fr1_gnb_build.xml @@ -26,7 +26,6 @@ wrench 000001 - 000002 @@ -36,7 +35,6 @@ -w USRP -c --gNB --ninja 0 0 - True True diff --git a/ci-scripts/xml_files/fr1_lte_2x2_quectel.xml b/ci-scripts/xml_files/fr1_lte_2x2_quectel.xml new file mode 100644 index 0000000000..03d474aef0 --- /dev/null +++ b/ci-scripts/xml_files/fr1_lte_2x2_quectel.xml @@ -0,0 +1,141 @@ + + + TEST-LTE-TM2 + LTE 2x2 Ping DL UL with QUECTEL + tasks + 1 + + 030000 + 000002 + 010000 + 000001 + 050000 + 050001 + 000002 + 070000 + 070001 + 000001 + 010002 + 080000 + + + + + Initialize_UE + Initialize Quectel + nrmodule2_quectel + yes + + + + + Terminate_UE + Terminate Quectel + nrmodule2_quectel + + + + + Initialize_eNB + Initialize eNB + -O ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 + 0 + 0 + lte + yes + yes + 192.168.18.241 + + + + + IdleSleep + Sleep + 5 + + + + IdleSleep + Sleep + 20 + + + + + Ping + Ping: 20 pings + nrmodule2_quectel + -c 20 + 5 + + + Ping + Ping: 100 pings, size 1024 + nrmodule2_quectel + -c 100 -s 1024 -i 0,2 + 5 + + + + + Iperf + iperf (DL/26Mbps/UDP)(60 sec)(single-ue profile) + -u -b 26M -t 60 + DL + nrmodule2_quectel + 5 + single-ue + + + + Iperf + iperf (UL/7Mbps/UDP)(60 sec)(single-ue profile) + -u -b 7M -t 60 + UL + nrmodule2_quectel + 5 + single-ue + + + + + + + Terminate_eNB + Terminate eNB + 0 + 0 + lte + + + + Terminate_eNB + Terminate gNB + 1 + 1 + nr + + + + diff --git a/ci-scripts/xml_files/fr1_multi_node_build.xml b/ci-scripts/xml_files/fr1_multi_node_build.xml index 57c4685341..60bc734e65 100644 --- a/ci-scripts/xml_files/fr1_multi_node_build.xml +++ b/ci-scripts/xml_files/fr1_multi_node_build.xml @@ -26,7 +26,7 @@ wrench 000001 000002 - 000003 000004 + 000004 000005 000003 @@ -64,5 +64,10 @@ 1 + + IdleSleep + Sleep + 120 + diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml index a8e385b854..16dfd1e377 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml @@ -21,10 +21,10 @@ --> - TEST-NSA-FR1-TM1 - NSA Ping DL UL with QUECTEL + TEST-NSA-FR1-TM2-Tab1 + NSA 2x2 Ping DL UL with QUECTEL tasks - 1 + 5 030000 040000 @@ -32,6 +32,10 @@ 010000 000001 050000 + 050001 + 000002 + 070000 + 070001 000001 010002 080001 @@ -57,11 +61,12 @@ Initialize_eNB Initialize eNB - -O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf + -O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 0 0 lte yes + yes 192.168.18.241 @@ -69,17 +74,18 @@ Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q + -O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 1 1 nr + yes 192.168.18.240 IdleSleep Sleep - 5 + 60 @@ -94,15 +100,15 @@ Ping: 20pings in 20sec nrmodule2_quectel -c 20 - 50 + 5 Ping Ping: 100pings in 20sec nrmodule2_quectel - -c 100 -i 0.2 - 50 + -c 100 -i 0,2 + 5 @@ -111,17 +117,17 @@ -u -b 20M -t 60 DL nrmodule2_quectel - 50 + 5 single-ue Iperf - iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) + iperf (UL/1Mbps/UDP)(20 sec)(single-ue profile) -u -b 3M -t 60 UL nrmodule2_quectel - 50 + 5 single-ue diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml new file mode 100644 index 0000000000..ebb5c880d5 --- /dev/null +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml @@ -0,0 +1,145 @@ + + + TEST-NSA-FR1-TM2-Tab2 + NSA 2x2 Attach-Detach with QUECTEL + tasks + 5 + + 031000 + 041000 + 000002 + 010000 + 000001 + 050000 + 000002 + 010004 + 000002 + 010003 + 000001 + 050000 + 000002 + 010004 + 000002 + 010003 + 000001 + 050000 + 000002 + 010002 + 080001 + 080000 + + + + + Initialize_UE + Initialize Quectel + nrmodule2_quectel + yes + + + + + Terminate_UE + Terminate Quectel + nrmodule2_quectel + + + + Attach_UE + Attach Quectel + nrmodule2_quectel + + + + Detach_UE + Detach Quectel + nrmodule2_quectel + + + + + Initialize_eNB + Initialize eNB + -O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 + 0 + 0 + lte + yes + yes + 192.168.18.241 + + + + + Initialize_eNB + Initialize gNB + -O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 + 1 + 1 + nr + yes + 192.168.18.240 + + + + IdleSleep + Sleep + 60 + + + + IdleSleep + Sleep + 20 + + + + + Ping + Ping: 20pings in 20sec + nrmodule2_quectel + -c 20 + 5 + + + + + + Terminate_eNB + Terminate eNB + 0 + 0 + lte + + + + Terminate_eNB + Terminate gNB + 1 + 1 + nr + + + + diff --git a/ci-scripts/xml_files/fr1_oai_cn_deploy.xml b/ci-scripts/xml_files/fr1_oai_cn_deploy.xml index 919def7aa3..26dbebc329 100644 --- a/ci-scripts/xml_files/fr1_oai_cn_deploy.xml +++ b/ci-scripts/xml_files/fr1_oai_cn_deploy.xml @@ -33,7 +33,7 @@ Deploy_EPC Deploy all EPC containers - yaml_files/fr1_epc_tim + yaml_files/magma_nsa_20897 diff --git a/ci-scripts/xml_files/fr1_sa_quectel.xml b/ci-scripts/xml_files/fr1_sa_quectel.xml index 4c8fba0611..b401465f80 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel.xml @@ -31,6 +31,9 @@ 010000 000001 050000 + 050001 + 070000 + 070001 000001 010002 080000 @@ -55,11 +58,12 @@ Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf --sa -q + -O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 0 0 nr yes + yes 192.168.18.240 @@ -81,15 +85,15 @@ Ping: 20pings in 20sec nrmodule2_quectel -c 20 - 50 + 5 Ping Ping: 100pings in 20sec nrmodule2_quectel - -c 100 -i 0.2 - 50 + -c 100 -i 0,2 + 5 @@ -98,7 +102,7 @@ -u -b 20M -t 60 DL nrmodule2_quectel - 50 + 5 single-ue @@ -108,7 +112,7 @@ -u -b 3M -t 60 UL nrmodule2_quectel - 50 + 5 single-ue diff --git a/ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml similarity index 95% rename from ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml rename to ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml index 73a6b3a1ff..0005ce8844 100644 --- a/ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml +++ b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml @@ -51,7 +51,7 @@ services: LTE_K: FEC86BA6EB707ED08905757B1BB44B8F APN1: oai.ipv4 APN2: oai2.ipv4 - FIRST_IMSI: 208990100001127 + FIRST_IMSI: 208970100001127 NB_USERS: 5 healthcheck: test: /bin/bash -c "pgrep oai_hss" @@ -78,7 +78,7 @@ services: HSS_FQDN: hss.openairinterface.org HSS_REALM: openairinterface.org MCC: '208' - MNC: '99' + MNC: '97' MME_GID: 32768 MME_CODE: 3 TAC_0: 1 @@ -97,15 +97,15 @@ services: PEER_MME_IPV4_ADDRESS_FOR_S10_0: 0.0.0.0 PEER_MME_IPV4_ADDRESS_FOR_S10_1: 0.0.0.0 MCC_SGW_0: '208' - MNC3_SGW_0: '099' + MNC3_SGW_0: '097' TAC_LB_SGW_0: '01' TAC_HB_SGW_0: '00' MCC_MME_0: '208' - MNC3_MME_0: '099' + MNC3_MME_0: '097' TAC_LB_MME_0: '02' TAC_HB_MME_0: '00' MCC_MME_1: '208' - MNC3_MME_1: '099' + MNC3_MME_1: '097' TAC_LB_MME_1: '03' TAC_HB_MME_1: '00' TAC_LB_SGW_TEST_0: '03' @@ -138,11 +138,12 @@ services: UE_IP_ADDRESS_POOL_1: '12.1.1.2 - 12.1.1.254' UE_IP_ADDRESS_POOL_2: '12.0.0.2 - 12.0.0.254' MCC: '208' - MNC: '99' - MNC03: '099' + MNC: '97' + MNC03: '097' TAC: 1 GW_ID: 1 REALM: openairinterface.org + UE_MTU_IPV4: 1500 healthcheck: test: /bin/bash -c "pgrep oai_spgwc" interval: 10s @@ -168,8 +169,8 @@ services: NETWORK_UE_IP: '12.1.1.0/24' NETWORK_UE_NAT_OPTION: 'yes' MCC: '208' - MNC: '99' - MNC03: '099' + MNC: '97' + MNC03: '097' TAC: 1 GW_ID: 1 REALM: openairinterface.org diff --git a/ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml.orig b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml similarity index 62% rename from ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml.orig rename to ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml index 28ae154838..df14e900e7 100644 --- a/ci-scripts/yaml_files/fr1_epc_tim/docker-compose.yml.orig +++ b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml @@ -40,17 +40,18 @@ services: private_net: ipv4_address: 192.168.68.3 public_net: - ipv4_address: 192.168.61.2 + ipv4_address: 192.168.61.194 environment: + TZ: Europe/Paris REALM: openairinterface.org HSS_FQDN: hss.openairinterface.org PREFIX: /openair-hss/etc cassandra_Server_IP: 192.168.68.2 OP_KEY: 1006020f0a478bf6b699f15c062e42b3 - LTE_K: fec86ba6eb707ed08905757b1bb44b8f + LTE_K: FEC86BA6EB707ED08905757B1BB44B8F APN1: oai.ipv4 - APN2: internet - FIRST_IMSI: 222010100001120 + APN2: oai2.ipv4 + FIRST_IMSI: 208970100001127 NB_USERS: 10 healthcheck: test: /bin/bash -c "pgrep oai_hss" @@ -58,57 +59,45 @@ services: timeout: 5s retries: 5 - oai_mme: - image: oai-mme:production - container_name: prod-oai-mme + redis: + image: redis:6.0.5 + container_name: prod-redis privileged: true - depends_on: [oai_hss] networks: public_net: - ipv4_address: 192.168.61.3 + ipv4_address: 192.168.61.198 + volumes: + - ./redis_extern.conf:/usr/local/etc/redis/redis.conf + entrypoint: /bin/bash -c "redis-server /usr/local/etc/redis/redis.conf" + healthcheck: + test: /bin/bash -c "redis-cli -h 192.168.61.198 -p 6380 ping" + interval: 10s + timeout: 5s + retries: 5 + + magma_mme: + image: magma-mme:production + container_name: prod-magma-mme + hostname: mme + privileged: true + depends_on: [oai_hss, redis] + networks: + public_net: + ipv4_address: 192.168.61.195 environment: + TZ: Europe/Paris REALM: openairinterface.org PREFIX: /openair-mme/etc - INSTANCE: 1 - PID_DIRECTORY: /var/run - HSS_IP_ADDR: 192.168.61.2 HSS_HOSTNAME: hss HSS_FQDN: hss.openairinterface.org HSS_REALM: openairinterface.org - MCC: '222' - MNC: '01' - MME_GID: 32768 - MME_CODE: 3 - TAC_0: 1 - TAC_1: 2 - TAC_2: 3 MME_FQDN: mme.openairinterface.org - MME_S6A_IP_ADDR: 192.168.61.3 - MME_INTERFACE_NAME_FOR_S1_MME: eth0 - MME_IPV4_ADDRESS_FOR_S1_MME: 192.168.61.3 - MME_INTERFACE_NAME_FOR_S11: eth0 - MME_IPV4_ADDRESS_FOR_S11: 192.168.61.3 - MME_INTERFACE_NAME_FOR_S10: lo - MME_IPV4_ADDRESS_FOR_S10: 127.0.0.10 - OUTPUT: CONSOLE - SGW_IPV4_ADDRESS_FOR_S11_0: 192.168.61.4 - PEER_MME_IPV4_ADDRESS_FOR_S10_0: 0.0.0.0 - PEER_MME_IPV4_ADDRESS_FOR_S10_1: 0.0.0.0 - MCC_SGW_0: '222' - MNC3_SGW_0: '001' - TAC_LB_SGW_0: '01' - TAC_HB_SGW_0: '00' - MCC_MME_0: '222' - MNC3_MME_0: '001' - TAC_LB_MME_0: '02' - TAC_HB_MME_0: '00' - MCC_MME_1: '222' - MNC3_MME_1: '001' - TAC_LB_MME_1: '03' - TAC_HB_MME_1: '00' - TAC_LB_SGW_TEST_0: '03' - TAC_HB_SGW_TEST_0: '00' - SGW_IPV4_ADDRESS_FOR_S11_TEST_0: 0.0.0.0 + FEATURES: mme_oai + volumes: + - ./mme_fd.sprint.conf:/magma-mme/etc/mme_fd.conf.tmplt + - ./mme.conf:/magma-mme/etc/mme.conf + - ./entrypoint.sh:/magma-mme/bin/entrypoint.sh + entrypoint: /bin/bash -c "/magma-mme/bin/entrypoint.sh" healthcheck: test: /bin/bash -c "pgrep oai_mme" interval: 10s @@ -118,22 +107,30 @@ services: oai_spgwc: image: oai-spgwc:production privileged: true - depends_on: [oai_mme] + depends_on: [magma_mme] container_name: prod-oai-spgwc networks: public_net: - ipv4_address: 192.168.61.4 + ipv4_address: 192.168.61.196 environment: - PID_DIRECTORY: /var/run + TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 - SGW_IP_FOR_S5_S8_CP: 127.0.0.11/8 - PGW_IP_FOR_S5_S8_CP: 127.0.0.12/8 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_APN: oai.ipv4 DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 - UE_IP_ADDRESS_POOL: '12.1.1.2 - 12.1.1.254' - PUSH_PROTOCOL_OPTION: 'yes' + PUSH_PROTOCOL_OPTION: 'true' + APN_NI_1: oai.ipv4 + APN_NI_2: oai2.ipv4 + DEFAULT_APN_NI_1: oai.ipv4 + UE_IP_ADDRESS_POOL_1: '12.1.1.2 - 12.1.1.254' + UE_IP_ADDRESS_POOL_2: '12.0.0.2 - 12.0.0.254' + MCC: '208' + MNC: '97' + MNC03: '097' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + UE_MTU_IPV4: 1500 healthcheck: test: /bin/bash -c "pgrep oai_spgwc" interval: 10s @@ -147,45 +144,39 @@ services: depends_on: [oai_spgwc] networks: public_net: - ipv4_address: 192.168.61.5 + ipv4_address: 192.168.61.197 environment: + TZ: Europe/Paris PID_DIRECTORY: /var/run INSTANCE: 1 SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP: eth0 PGW_INTERFACE_NAME_FOR_SGI: eth0 SGW_INTERFACE_NAME_FOR_SX: eth0 - SPGWC0_IP_ADDRESS: 192.168.61.4 + SPGWC0_IP_ADDRESS: 192.168.61.196 NETWORK_UE_IP: '12.1.1.0/24' NETWORK_UE_NAT_OPTION: 'yes' + MCC: '208' + MNC: '97' + MNC03: '097' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org healthcheck: test: /bin/bash -c "pgrep oai_spgwu" interval: 10s timeout: 5s retries: 5 - flexran_rtc: - image: flexran-rtc:production - privileged: true - container_name: prod-flexran-rtc - networks: - public_net: - ipv4_address: 192.168.61.10 - healthcheck: - test: /bin/bash -c "pgrep rt_controller" - interval: 10s - timeout: 5s - retries: 5 - trf_gen: image: trf-gen:production privileged: true container_name: prod-trf-gen networks: public_net: - ipv4_address: 192.168.61.11 - entrypoint: /bin/bash -c "ip route add 12.1.1.0/24 via 192.168.61.5 dev eth0; sleep infinity" + ipv4_address: 192.168.61.200 + entrypoint: /bin/bash -c "ip route add 12.1.1.0/24 via 192.168.61.197 dev eth0; sleep infinity" healthcheck: - test: /bin/bash -c "ping -c 2 192.168.61.5" + test: /bin/bash -c "ip route | grep '12.1.1.0'" interval: 10s timeout: 5s retries: 5 @@ -196,8 +187,12 @@ networks: ipam: config: - subnet: 192.168.68.0/26 + driver_opts: + com.docker.network.bridge.name: "oai-priv-net" public_net: name: prod-oai-public-net ipam: config: - - subnet: 192.168.61.0/26 + - subnet: 192.168.61.192/26 + driver_opts: + com.docker.network.bridge.name: "oai-pub-net" diff --git a/ci-scripts/yaml_files/magma_nsa_20897/entrypoint.sh b/ci-scripts/yaml_files/magma_nsa_20897/entrypoint.sh new file mode 100755 index 0000000000..859ff7d98f --- /dev/null +++ b/ci-scripts/yaml_files/magma_nsa_20897/entrypoint.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +INSTANCE=1 +PREFIX='/magma-mme/etc' +MY_REALM='openairinterface.org' + +declare -A MME_CONF + +pushd $PREFIX +MME_CONF[@MME_S6A_IP_ADDR@]="192.168.61.195" +MME_CONF[@INSTANCE@]=$INSTANCE +MME_CONF[@PREFIX@]=$PREFIX +MME_CONF[@REALM@]=$MY_REALM +MME_CONF[@MME_FQDN@]="mme.${MME_CONF[@REALM@]}" +MME_CONF[@HSS_HOSTNAME@]='hss' +MME_CONF[@HSS_FQDN@]="${MME_CONF[@HSS_HOSTNAME@]}.${MME_CONF[@REALM@]}" +MME_CONF[@HSS_IP_ADDR@]="192.168.61.194" + +cp mme_fd.conf.tmplt $PREFIX/mme_fd.conf + +for K in "${!MME_CONF[@]}"; do + egrep -lRZ "$K" $PREFIX/mme_fd.conf | xargs -0 -l sed -i -e "s|$K|${MME_CONF[$K]}|g" + ret=$?;[[ ret -ne 0 ]] && echo "Tried to replace $K with ${MME_CONF[$K]}" +done + +sed -i -e "s@etc/freeDiameter@etc@" /magma-mme/etc/mme_fd.conf +sed -i -e "s@bind: 127.0.0.1@bind: 192.168.61.198@" /etc/magma/redis.yml +# Generate freeDiameter certificate +popd +cd /magma-mme/scripts +./check_mme_s6a_certificate $PREFIX mme.${MME_CONF[@REALM@]} + +cd /magma-mme +nohup /magma-mme/bin/sctpd > /var/log/sctpd.log 2>&1 & +sleep 5 +/magma-mme/bin/oai_mme -c /magma-mme/etc/mme.conf diff --git a/ci-scripts/yaml_files/magma_nsa_20897/mme.conf b/ci-scripts/yaml_files/magma_nsa_20897/mme.conf new file mode 100644 index 0000000000..e41fbe6304 --- /dev/null +++ b/ci-scripts/yaml_files/magma_nsa_20897/mme.conf @@ -0,0 +1,136 @@ +# generated by generate_mme_config_script.py +MME : +{ + REALM = "openairinterface.org" + PID_DIRECTORY = "/var/run"; + MAXENB = 8; # power of 2 + MAXUE = 16; # power of 2 + RELATIVE_CAPACITY = 10; + + EMERGENCY_ATTACH_SUPPORTED = "no"; + UNAUTHENTICATED_IMSI_SUPPORTED = "no"; + + # EPS network feature support + EPS_NETWORK_FEATURE_SUPPORT_IMS_VOICE_OVER_PS_SESSION_IN_S1 = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_EMERGENCY_BEARER_SERVICES_IN_S1_MODE = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_LOCATION_SERVICES_VIA_EPC = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_EXTENDED_SERVICE_REQUEST = "no"; # DO NOT CHANGE + + # Display statistics about whole system (expressed in seconds) + MME_STATISTIC_TIMER = 10; + IP_CAPABILITY = "IPV4"; # UE PDN_TYPE + USE_STATELESS = ""; + + INTERTASK_INTERFACE : + { + # max queue size per task + ITTI_QUEUE_SIZE = 2000000; + }; + + S6A : + { + S6A_CONF = "/magma-mme/etc/mme_fd.conf"; # YOUR MME freeDiameter config file path + HSS_HOSTNAME = "hss.openairinterface.org"; + HSS_REALM = "openairinterface.org"; + }; + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 8; + SCTP_OUTSTREAMS = 8; + }; + + # ------- S1AP definitions + S1AP : + { + # outcome drop timer value (seconds) + S1AP_OUTCOME_TIMER = 10; + }; + + # ------- MME served GUMMEIs + GUMMEI_LIST = ( + { MCC="208" ; MNC="97"; MME_GID="32768" ; MME_CODE="3"; } + ); + + # ------- MME served TAIs + TAI_LIST = ( + {MCC="208" ; MNC="97"; TAC = "1"; }, + {MCC="208" ; MNC="97"; TAC = "2"; }, + {MCC="208" ; MNC="97"; TAC = "3"; } + ); + + TAC_LIST = ( + {MCC="208" ; MNC="97"; TAC = "1"; } + ); + + CSFB : + { + NON_EPS_SERVICE_CONTROL = "OFF"; + CSFB_MCC = "208"; + CSFB_MNC = "97"; + LAC = "1"; + }; + NAS : + { + ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "EIA2" , "EIA1" , "EIA0" ]; + ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "EEA0" , "EEA1" , "EEA2" ]; + T3402 = 1 # in minutes (default is 12 minutes) + T3412 = 54 # in minutes (default is 54 minutes, network dependent) + T3422 = 6 # in seconds (default is 6s) + T3450 = 6 # in seconds (default is 6s) + T3460 = 6 # in seconds (default is 6s) + T3470 = 6 # in seconds (default is 6s) + T3485 = 8 # UNUSED in seconds (default is 8s) + T3486 = 8 # UNUSED in seconds (default is 8s) + T3489 = 4 # UNUSED in seconds (default is 4s) + T3495 = 8 # UNUSED in seconds (default is 8s) + }; + + SGS : + { + TS6_1 = 10 # in seconds (default is 10s) + TS8 = 4 # in seconds (default is 4s) + TS9 = 2 # in seconds (default is 4s) + TS10 = 4 # in seconds (default is 4s) + TS13 = 4 # in seconds (default is 4s) + }; + + NETWORK_INTERFACES : + { + MME_INTERFACE_NAME_FOR_S1_MME = "eth0"; + MME_IPV4_ADDRESS_FOR_S1_MME = "192.168.61.195/24"; + MME_INTERFACE_NAME_FOR_S11_MME = "eth0"; + MME_IPV4_ADDRESS_FOR_S11_MME = "192.168.61.195/24"; + MME_PORT_FOR_S11_MME = 2123; + }; + + LOGGING : + { + OUTPUT = "CONSOLE"; + THREAD_SAFE = "no"; + COLOR = "no"; + + SCTP_LOG_LEVEL = "ERROR"; + GTPV1U_LOG_LEVEL = "INFO"; + SPGW_APP_LOG_LEVEL = "INFO"; + UDP_LOG_LEVEL = "INFO"; + S1AP_LOG_LEVEL = "DEBUG"; + NAS_LOG_LEVEL = "INFO"; + MME_APP_LOG_LEVEL = "DEBUG"; + GTPV2C_LOG_LEVEL = "INFO"; + S11_LOG_LEVEL = "DEBUG"; + S6A_LOG_LEVEL = "DEBUG"; + UTIL_LOG_LEVEL = "INFO"; + MSC_LOG_LEVEL = "ERROR"; + ITTI_LOG_LEVEL = "ERROR"; + MME_SCENARIO_PLAYER_LOG_LEVEL = "ERROR"; + ASN1_VERBOSITY = "INFO"; + }; + + S-GW : + { + SGW_IPV4_ADDRESS_FOR_S11 = "192.168.61.196"; + }; +}; diff --git a/ci-scripts/yaml_files/magma_nsa_20897/mme_fd.sprint.conf b/ci-scripts/yaml_files/magma_nsa_20897/mme_fd.sprint.conf new file mode 100644 index 0000000000..6f87ed8c2b --- /dev/null +++ b/ci-scripts/yaml_files/magma_nsa_20897/mme_fd.sprint.conf @@ -0,0 +1,169 @@ +# -------- Local --------- + +# Uncomment if the framework cannot resolv it. +Identity = "@MME_FQDN@"; +Realm = "@REALM@"; + +# TLS configuration (see previous section) +TLS_Cred = "@PREFIX@/freeDiameter/mme.cert.pem", + "@PREFIX@/freeDiameter/mme.key.pem"; +TLS_CA = "@PREFIX@/freeDiameter/mme.cacert.pem"; + +# Disable use of TCP protocol (only listen and connect in SCTP) +# Default : TCP enabled +No_SCTP; + +# This option is ignored if freeDiameter is compiled with DISABLE_SCTP option. +# Prefer TCP instead of SCTP for establishing new connections. +# This setting may be overwritten per peer in peer configuration blocs. +# Default : SCTP is attempted first. +Prefer_TCP; + + +No_IPv6; + +# Overwrite the number of SCTP streams. This value should be kept low, +# especially if you are using TLS over SCTP, because it consumes a lot of +# resources in that case. See tickets 19 and 27 for some additional details on +# this. +# Limit the number of SCTP streams +SCTP_streams = 3; + + +# By default, freeDiameter acts as a Diameter Relay Agent by forwarding all +# messages it cannot handle locally. This parameter disables this behavior. +NoRelay; + +# Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed +# on the unsecure connection. The alternative is RFC6733 mechanism, where TLS protects also the +# CER/CEA exchange on a dedicated secure port. +# This parameter only affects outgoing connections. +# The setting can be also defined per-peer (see Peers configuration section). +# Default: use RFC6733 method with separate port for TLS. + +#TLS_old_method; + +AppServThreads = 4; + +# Specify the addresses on which to bind the listening server. This must be +# specified if the framework is unable to auto-detect these addresses, or if the +# auto-detected values are incorrect. Note that the list of addresses is sent +# in CER or CEA message, so one should pay attention to this parameter if some +# adresses should be kept hidden. +ListenOn = "@MME_S6A_IP_ADDR@"; + +Port = 3870; +SecPort = 5870; + +# -------- Extensions --------- + +# Uncomment (and create rtd.conf) to specify routing table for this peer. +#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx" : "rtd.conf"; + +#LoadExtension = "/usr/local/lib/freeDiameter/_sample.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_acct.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_diameap.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_radgw.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_redirect.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_sip.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_interactive.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_monitor.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_dumps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_timings.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_rt.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_CreditControl.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_CxDx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Gx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_NAS.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Ro.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_S6mS6n.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_SGd.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_SLh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sd.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_T4.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_T6aT6bT7.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Tsp.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_3gpp.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_starent.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_eap.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_etsi283034_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_legacy_xml.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6a.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6i.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_nas_mipv6.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_nasreq.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4004_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4006bis_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4072_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4590_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5447_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5580_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5777_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5778_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6734_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6942_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7155_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7683_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7944_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_sip.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29061_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29128_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29154_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29173_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29212_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29214_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29215_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29217_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29229_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29272_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29273_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29329_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29336_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29337_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29338_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29343_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29344_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29345_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29368_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29468_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts32299_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_busypeers.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_ereg.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_ignore_dh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_load_balance.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_randomize.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_redirect.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_acct.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_hss.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_netemul.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_rt_any.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_sip.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rf.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6as6d.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6c.fdx"; + + +# -------- Peers --------- + +# The framework will actively attempt to establish and maintain a connection +# with the peers listed here. +# For only accepting incoming connections, see the acl_wl.fx extension. + +# ConnectPeer +# Declare a remote peer to which this peer must maintain a connection. +# In addition, this allows specifying non-default parameters for this peer only +# (for example disable SCTP with this peer, or use RFC3588-flavour TLS). +# Note that by default, if a peer is not listed as a ConnectPeer entry, an +# incoming connection from this peer will be rejected. If you want to accept +# incoming connections from other peers, see the acl_wl.fdx? extension which +# allows exactly this. + +ConnectPeer= "@HSS_FQDN@" { ConnectTo = "@HSS_IP_ADDR@"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868;}; diff --git a/ci-scripts/yaml_files/magma_nsa_20897/redis_extern.conf b/ci-scripts/yaml_files/magma_nsa_20897/redis_extern.conf new file mode 100644 index 0000000000..565524080a --- /dev/null +++ b/ci-scripts/yaml_files/magma_nsa_20897/redis_extern.conf @@ -0,0 +1,33 @@ +# +# Copyright (c) 2016-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +# Jinja template for Redis configuration +# See the default config file for options and explanations: +# https://github.com/antirez/redis/blob/unstable/redis.conf + +# TODO: make sensible, production-aware config decisions + +bind 192.168.61.198 +port 6380 + +daemonize no +loglevel notice + +timeout 0 +databases 1 + +dbfilename redis_dump.rdb +dir /data + +# Save the DB on disk + +save 900 1 + +save 300 10 + +save 60 1000 diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index cad45fd7ef..8ad515625d 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -309,6 +309,7 @@ endif() # # add autotools definitions that were maybe used! + add_definitions("-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP") set(commonOpts "-pipe -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic") @@ -318,11 +319,7 @@ set(CMAKE_C_FLAGS set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11") -# cuda compiler bug (limitation) on complex macro definition -if (CUDA_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCUDA_FLAG") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_FLAG") -endif() + if (SANITIZE_ADDRESS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-common") @@ -1588,6 +1585,16 @@ set(PHY_LDPC_OPTIM8SEGMULTI_SRC ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c ) +set(PHY_LDPC_CUDA_SRC + ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu + ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c +) + +set(PHY_LDPC_CL_SRC + ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c + ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c +) + set(PHY_NR_CODINGIF ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_load.c; ) @@ -1595,8 +1602,18 @@ set(PHY_NR_CODINGIF add_library(ldpc_orig MODULE ${PHY_LDPC_ORIG_SRC} ) add_library(ldpc_optim MODULE ${PHY_LDPC_OPTIM_SRC} ) add_library(ldpc_optim8seg MODULE ${PHY_LDPC_OPTIM8SEG_SRC} ) +add_library(ldpc_cl MODULE ${PHY_LDPC_CL_SRC} ) +target_link_libraries(ldpc_cl OpenCL) + +if (CUDA_FOUND) + cuda_add_library(ldpc_cuda MODULE ${PHY_LDPC_CUDA_SRC} ) + set_target_properties(ldpc_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +# CUDA_ADD_CUFFT_TO_TARGET(ldpc_cuda) +endif (CUDA_FOUND) + add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} ) + add_library(coding MODULE ${PHY_TURBOSRC} ) add_library(dfts MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts.c ) @@ -1742,7 +1759,6 @@ set(PHY_SRC_UE set(PHY_NR_SRC_COMMON ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c - ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dci_tools_common.c ) set(PHY_NR_SRC @@ -1981,6 +1997,10 @@ set(NR_PDCP_SRC ${OPENAIR2_DIR}/LAYER2/nr_pdcp/asn1_utils.c ) +set(NR_SDAP_SRC + ${OPENAIR2_DIR}/SDAP/nr_sdap/nr_sdap_gnb.c + ) + set(L2_SRC ${PDCP_DIR}/pdcp.c ${PDCP_DIR}/pdcp_fifo.c @@ -2024,6 +2044,7 @@ set(L2_LTE_SRC set(L2_NR_SRC ${NR_RLC_SRC} ${NR_PDCP_SRC} + ${NR_SDAP_SRC} ${NR_RRC_DIR}/rrc_gNB.c ${NR_RRC_DIR}/nr_rrc_common.c ${NR_RRC_DIR}/L2_nr_interface.c @@ -2059,6 +2080,7 @@ set(L2_RRC_SRC_UE set(NR_L2_SRC_UE ${NR_RLC_SRC} ${NR_PDCP_SRC} + ${NR_SDAP_SRC} ${NR_UE_RRC_DIR}/L2_interface_ue.c ${NR_UE_RRC_DIR}/main_ue.c ${NR_UE_RRC_DIR}/rrc_UE.c @@ -3110,7 +3132,11 @@ target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-uesoftmodem ${T_LIB}) add_dependencies( nr-uesoftmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) - +if (CUDA_FOUND) + add_dependencies( nr-uesoftmodem ldpc_cuda) + add_dependencies( nr-softmodem ldpc_cuda) + add_dependencies( ocp-gnb ldpc_cuda) +endif (CUDA_FOUND) ###################################" # Addexecutables for tests #################################### @@ -3170,46 +3196,18 @@ target_link_libraries(smallblocktest m pthread ${ATLAS_LIBRARIES} dl ) -if (CUDA_FOUND) -################################################### -# For CUDA library -################################################### - CUDA_ADD_LIBRARY(LDPC_CU - ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu - ) - CUDA_ADD_CUFFT_TO_TARGET(LDPC_CU) - cuda_add_executable(ldpctest - ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c - ${T_SOURCE} - ${SHLIB_LOADER_SOURCES} - ) - target_link_libraries(ldpctest -ldl - -Wl,--start-group - LDPC_CU UTIL SIMU PHY_NR CONFIG_LIB - -Wl,--end-group - m pthread ${ATLAS_LIBRARIES} dl - ) +add_executable(ldpctest + ${PHY_NR_CODINGIF} + ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) -else (CUDA_FOUND) - add_executable(ldpctest - ${PHY_NR_CODINGIF} - ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c - ${T_SOURCE} - ${SHLIB_LOADER_SOURCES} - ) - -endif () - - -# add_executable(ldpctest - # ${PHY_NR_CODINGIF} - # ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c - # ${T_SOURCE} - # ${SHLIB_LOADER_SOURCES} - # ) add_dependencies( ldpctest ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) - +if (CUDA_FOUND) + add_dependencies( ldpctest ldpc_cuda) +endif (CUDA_FOUND) target_link_libraries(ldpctest -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index c9390d67ce..c68ca8a553 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -551,7 +551,7 @@ function main() { if [ "$HW" == "OAI_USRP" ] ; then echo_info "installing packages for USRP support" check_install_usrp_uhd_driver - if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then + if [ ! -v BUILD_UHD_FROM_SOURCE ] && [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then install_usrp_uhd_driver $UHD_IMAGES_DIR fi fi diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index d3fcf615e2..c5cc9d054d 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -317,19 +317,30 @@ install_usrp_uhd_driver_from_source(){ echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " ( pushd /tmp - echo "Downloading UHD driver" + echo "Cloning UHD driver repository" rm -rf /tmp/uhd git clone https://github.com/EttusResearch/uhd.git cd uhd - git checkout tags/v4.0.0.0 + if [[ -v UHD_VERSION ]]; then + git checkout tags/v${UHD_VERSION} + else + git checkout tags/v4.0.0.0 + fi mkdir -p host/build - cd host/build - $CMAKE ../ + cd host/build || true + $CMAKE ../ -GNinja echo "Compiling UHD" - make -j`nproc` - make test - $SUDO make install + ninja + $SUDO ninja install $SUDO ldconfig -v + if [ $IS_CONTAINER -eq 0 ]; then + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + $SUDO /usr/local/lib/uhd/utils/uhd_images_downloader.py + fi + if [[ "$OS_DISTRO" == "rhel" ]]; then + $SUDO /usr/local/lib64/uhd/utils/uhd_images_downloader.py + fi + fi popd rm -rf /tmp/uhd ) >& $uhd_install_log @@ -338,10 +349,26 @@ install_usrp_uhd_driver_from_source(){ check_install_usrp_uhd_driver(){ if [[ "$OS_DISTRO" == "ubuntu" ]]; then #first we remove old installation - $SUDO apt-get remove -y uhd || true - $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y || true + $SUDO apt-get remove uhd -y || true + $SUDO apt-get remove uhd-host -y || true + $SUDO apt-get remove libuhd-dev -y || true + $SUDO apt-get remove libuhd003 -y || true + $SUDO apt-get remove libuhd3.13.1 -y || true + $SUDO apt-get remove libuhd3.14.0 -y || true + $SUDO apt-get remove libuhd3.14.1 -y || true + $SUDO apt-get remove libuhd3.15.0 -y || true + local distribution=$(get_distribution_release) + if [[ "$distribution" == "ubuntu18.04" ]]; then + $SUDO apt-get remove libuhd4.0.0 -y || true + $SUDO apt-get remove libuhd4.1.0 -y || true + fi v=$(lsb_release -cs) $SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main" + if [[ -v BUILD_UHD_FROM_SOURCE ]]; then + $SUDO apt-get install -y libboost-all-dev libusb-1.0-0-dev doxygen python3-docutils python3-mako python3-numpy python3-requests python3-setuptools ninja-build + install_usrp_uhd_driver_from_source + return + fi # The new USRP repository # Raphael Defosseux: Adding a loop on adding PPA because in CI the gpg key retrieve may # timeout due to proxy / network latencies in Eurecom on VM @@ -361,7 +388,12 @@ check_install_usrp_uhd_driver(){ done $SUDO apt-get update $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev - $SUDO apt-get -y install libuhd-dev libuhd003 uhd-host + if [[ "$distribution" == "ubuntu16.04" ]]; then + $SUDO apt-get -y install libuhd-dev libuhd3.15.0 uhd-host + fi + if [[ "$distribution" == "ubuntu18.04" ]]; then + $SUDO apt-get -y install libuhd-dev libuhd4.1.0 uhd-host + fi elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then if [ $IS_CONTAINER -eq 0 ] then @@ -692,6 +724,7 @@ check_install_oai_software() { build-essential \ $CMAKE \ cmake-curses-gui \ + curl \ ninja-build \ doxygen \ doxygen-gui \ diff --git a/common/utils/DOC/loader/devusage/api.md b/common/utils/DOC/loader/devusage/api.md index a6e59c5938..41a0807a24 100644 --- a/common/utils/DOC/loader/devusage/api.md +++ b/common/utils/DOC/loader/devusage/api.md @@ -10,6 +10,10 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf) * If the farray pointer is null, looks for `< modname >_getfarray` symbol, calls the corresponding function when the symbol is found. `< modname >_getfarray` takes one argument, a pointer to a `loader_shlibfunc_t` array, and returns the number of items in this array, as defined by the `getfarrayfunc_t` type. The `loader_shlibfunc_t` array returned by the shared library must be fully filled (both `fname` and `fptr` fields). * looks for the `numf` function symbols listed in the `farray[i].fname` arguments and set the corresponding `farray[i].fptr`function pointers +```c +int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf) +``` +Allows loading a specific library version, as specified by the `version` parameter. When version is not NULL the version that is possibly specified as a config module parameter is ignored. This call has been introduced for phy simulators executables which do not use the config module. It is used, for example, by the ldcp initialization (`load_nrLDPClib` function in [nrLDPC_load.c](../../../../../openair1/PHY/CODING/nrLDPC_load.c) to allow the `ldpctest` simulator to select the cuda accelerated ldcp implementation. `load_module_shlib` is just a define macro to switch to a `load_module_version_shlib` call, adding a NULL pointer for the version parameter. ```c void * get_shlibmodule_fptr(char *modname, char *fname) diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index a4b4742c94..2b0d339358 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -63,7 +63,7 @@ void loader_init(void) { } /* build the full shared lib name from the module name */ -char *loader_format_shlibpath(char *modname) +char *loader_format_shlibpath(char *modname, char *version) { char *tmpstr; @@ -97,7 +97,10 @@ int ret; shlibpath = loader_data.shlibpath ; } /* no specific shared lib version */ - if (shlibversion == NULL) { + if (version != NULL) { // version specified as a function parameter + shlibversion=version; + } + if (shlibversion == NULL) { // no specific version specified, neither as a config param or as a function param shlibversion = "" ; } /* alloc memory for full module shared lib file name */ @@ -118,7 +121,7 @@ int ret; return tmpstr; } -int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf, void *autoinit_arg) +int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf, void *autoinit_arg) { void *lib_handle = NULL; initfunc_t fpi; @@ -138,7 +141,7 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf, void * loader_init(); } - shlib_path = loader_format_shlibpath(modname); + shlib_path = loader_format_shlibpath(modname, version); for (int i = 0; i < loader_data.numshlibs; i++) { if (strcmp(loader_data.shlibs[i].name, modname) == 0) { diff --git a/common/utils/load_module_shlib.h b/common/utils/load_module_shlib.h index 685b3d1b65..0e80a5353c 100644 --- a/common/utils/load_module_shlib.h +++ b/common/utils/load_module_shlib.h @@ -84,10 +84,11 @@ loader_data_t loader_data; /*-------------------------------------------------------------------------------------------------------------*/ #else /* LOAD_MODULE_SHLIB_MAIN */ -extern int load_module_shlib(char *modname, loader_shlibfunc_t *farray, int numf, void *initfunc_arg); + +extern int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf, void *initfunc_arg); extern void * get_shlibmodule_fptr(char *modname, char *fname); extern loader_data_t loader_data; #endif /* LOAD_MODULE_SHLIB_MAIN */ - +#define load_module_shlib(M, F, N, I) load_module_version_shlib(M, NULL, F, N, I) #endif diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 8ba4633604..0a532c346b 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -34,6 +34,8 @@ #include "assertions.h" #include "nr_common.h" +const char *duplex_mode[]={"FDD","TDD"}; + // Table 5.2-1 NR operating bands in FR1 & FR2 (3GPP TS 38.101) // Table 5.4.2.3-1 Applicable NR-ARFCN per operating band in FR1 & FR2 (3GPP TS 38.101) // Notes: @@ -231,6 +233,30 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx) { } +void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) { + + uint8_t count=0, start=0, start_set=0; + + uint64_t bitmap = (((uint64_t)FreqDomainResource[0])<<37)| + (((uint64_t)FreqDomainResource[1])<<29)| + (((uint64_t)FreqDomainResource[2])<<21)| + (((uint64_t)FreqDomainResource[3])<<13)| + (((uint64_t)FreqDomainResource[4])<<5)| + (((uint64_t)FreqDomainResource[5])>>3); + + for (int i=0; i<45; i++) + if ((bitmap>>(44-i))&1) { + count++; + if (!start_set) { + start = i; + start_set = 1; + } + } + *rb_offset = 6*start; + *n_rb = 6*count; +} + + int get_dmrs_port(int nl, uint16_t dmrs_ports) { if (dmrs_ports == 0) return 0; // dci 1_0 @@ -249,6 +275,176 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) { return p; } +int get_num_dmrs(uint16_t dmrs_mask ) { + + int num_dmrs=0; + + for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1); + return(num_dmrs); +} + +lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index) +{ + lte_frame_type_t current_type; + int32_t delta_duplex = get_delta_duplex(current_band, scs_index); + + if (delta_duplex == 0) + current_type = TDD; + else + current_type = FDD; + + LOG_I(NR_MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[current_type], delta_duplex); + + return current_type; +} + +// Computes the duplex spacing (either positive or negative) in KHz +int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index) +{ + int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index); + + int32_t delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min); + + LOG_I(NR_MAC, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band); + + return delta_duplex; +} + +uint16_t config_bandwidth(int mu, int nb_rb, int nr_band) +{ + + if (nr_band < 100) { //FR1 + switch(mu) { + case 0 : + if (nb_rb<=25) + return 5; + if (nb_rb<=52) + return 10; + if (nb_rb<=79) + return 15; + if (nb_rb<=106) + return 20; + if (nb_rb<=133) + return 25; + if (nb_rb<=160) + return 30; + if (nb_rb<=216) + return 40; + if (nb_rb<=270) + return 50; + AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); + break; + case 1 : + if (nb_rb<=11) + return 5; + if (nb_rb<=24) + return 10; + if (nb_rb<=38) + return 15; + if (nb_rb<=51) + return 20; + if (nb_rb<=65) + return 25; + if (nb_rb<=78) + return 30; + if (nb_rb<=106) + return 40; + if (nb_rb<=133) + return 50; + if (nb_rb<=162) + return 60; + if (nb_rb<=189) + return 70; + if (nb_rb<=217) + return 80; + if (nb_rb<=245) + return 90; + if (nb_rb<=273) + return 100; + AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); + break; + case 2 : + if (nb_rb<=11) + return 10; + if (nb_rb<=18) + return 15; + if (nb_rb<=24) + return 20; + if (nb_rb<=31) + return 25; + if (nb_rb<=38) + return 30; + if (nb_rb<=51) + return 40; + if (nb_rb<=65) + return 50; + if (nb_rb<=79) + return 60; + if (nb_rb<=93) + return 70; + if (nb_rb<=107) + return 80; + if (nb_rb<=121) + return 90; + if (nb_rb<=135) + return 100; + AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); + break; + default: + AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band); + } + } + else { + switch(mu) { + case 2 : + if (nb_rb<=66) + return 50; + if (nb_rb<=132) + return 100; + if (nb_rb<=264) + return 200; + AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); + break; + case 3 : + if (nb_rb<=32) + return 50; + if (nb_rb<=66) + return 100; + if (nb_rb<=132) + return 200; + if (nb_rb<=264) + return 400; + AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); + break; + default: + AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band); + } + } +} + +// Returns the corresponding row index of the NR table +int get_nr_table_idx(int nr_bandP, uint8_t scs_index) { + int i, j; + int scs_khz = 15 << scs_index; + int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; + size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); + + for(j = 0; j < s; j++){ + if (nr_bandP == supplementary_bands[j]) + AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]); + } + + AssertFatal(nr_bandP <= nr_bandtable[nr_bandtable_size-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[nr_bandtable_size-1].band); + for (i = 0; i < nr_bandtable_size && nr_bandtable[i].band != nr_bandP; i++); + + // selection of correct Deltaf raster according to SCS + if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) + i++; + + LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min); + + return i; +} int get_subband_size(int NPRB,int size) { // implements table 5.2.1.4-2 from 36.214 diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index b3d2469a12..d9f2b0c03a 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -35,6 +35,7 @@ #include #include "assertions.h" +#include "PHY/defs_common.h" typedef struct nr_bandentry_s { int16_t band; @@ -50,6 +51,12 @@ typedef struct nr_bandentry_s { extern const size_t nr_bandtable_size; extern nr_bandentry_t nr_bandtable[]; +void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset); +int get_num_dmrs(uint16_t dmrs_mask); +uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); +int get_nr_table_idx(int nr_bandP, uint8_t scs_index); +int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index); +lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index); uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex); int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c index 734126721a..9e4eeca205 100644 --- a/common/utils/telnetsrv/telnetsrv.c +++ b/common/utils/telnetsrv/telnetsrv.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "common/utils/load_module_shlib.h" #include "common/config/config_userapi.h" #include "common/utils/threadPool/thread-pool.h" @@ -62,34 +63,27 @@ #include "telnetsrv_proccmd.h" static char *telnet_defstatmod[] = {"softmodem","phy","loader","measur"}; static telnetsrv_params_t telnetparams; -#define TELNETSRV_LISTENADDR 0 -#define TELNETSRV_LISTENPORT 1 -#define TELNETSRV_PRIORITY 2 -#define TELNETSRV_DEBUG 3 -#define TELNETSRV_LOOPC 4 -#define TELNETSRV_LOOPD 5 -#define TELNETSRV_HISFILE 6 -#define TELNETSRV_HISSIZE 7 -#define TELNETSRV_PHYBSIZE 8 -#define TELNETSRV_STATICMOD 9 -#define TELNETSRV_SHRMOD 10 + +#define TELNETSRV_OPTNAME_STATICMOD "staticmod" +#define TELNETSRV_OPTNAME_SHRMOD "shrmod" paramdef_t telnetoptions[] = { - /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - /* configuration parameters for telnet utility */ - /* optname helpstr paramflags XXXptr defXXXval type numelt */ - /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - {"listenaddr", "\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 }, - {"listenport", "\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 }, - {"priority", "\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 }, - {"loopcount", "\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 }, - {"loopdelay", "\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 }, - {"histfile", "\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 }, - {"histsize", "\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 }, - {"phypbsize", "\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 }, - {"staticmod", "\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))}, - {"shrmod", "\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 } + /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /* configuration parameters for telnet utility */ + /* optname helpstr paramflags XXXptr defXXXval type numelt */ + /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ + {"listenaddr", "\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 }, + {"listenport", "\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 }, + {"listenstdin", "enable input from stdin\n", PARAMFLAG_BOOL, uptr:&(telnetparams.listenstdin), defuintval:0, TYPE_UINT, 0 }, + {"priority", "\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 }, + {"loopcount", "\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 }, + {"loopdelay", "\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 }, + {"histfile", "\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 }, + {"histsize", "\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 }, + {"phypbsize", "\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 }, + {TELNETSRV_OPTNAME_STATICMOD, "\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))}, + {TELNETSRV_OPTNAME_SHRMOD, "\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 } }; int get_phybsize(void) { @@ -682,6 +676,77 @@ void run_telnetsrv(void) { return; } +void run_telnetclt(void) { + int sock; + struct sockaddr_in name; + pthread_setname_np(pthread_self(), "telnetclt"); + set_sched(pthread_self(),0,telnetparams.priority); + char prompt[sizeof(TELNET_PROMPT_PREFIX)+10]; + sprintf(prompt,"%s_%s> ",TELNET_PROMPT_PREFIX,get_softmodem_function(NULL)); + name.sin_family = AF_INET; + struct in_addr addr; + inet_aton("127.0.0.1", &addr) ; + name.sin_addr.s_addr = addr.s_addr; + name.sin_port = htons((unsigned short)(telnetparams.listenport)); + while (1) { + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) + fprintf(stderr,"[TELNETSRV] Error %s on socket call\n",strerror(errno)); + + if(connect(sock, (void *) &name, sizeof(name))) + fprintf(stderr,"[TELNETSRV] Error %s on connect call\n",strerror(errno)); + + struct timeval ts; + ts.tv_sec = 1; // 1 second + ts.tv_usec = 0; + while (1) { + fd_set fds; + FD_ZERO(&fds); + FD_SET(sock, &fds); + FD_SET(STDIN_FILENO , &fds); + // wait for data + int nready = select(sock + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts); + if (nready < 0) { + perror("select. Error"); + break; + } + else if (nready == 0) { + ts.tv_sec = 1; // 1 second + ts.tv_usec = 0; + } + else if ( FD_ISSET(sock, &fds)) { + int rv; + char inbuf[TELNET_MAX_MSGLENGTH*2]; + memset(inbuf,0,sizeof(inbuf)); + rv = recv(sock , inbuf , sizeof(inbuf)-1 , 0); + if (rv > 0) { + printf("%s",inbuf); + } + else if (rv == 0) { + printf("Connection closed by the remote end\n\r"); + break; + } + else { + perror("recv error"); + break; + } + } + else if (FD_ISSET(STDIN_FILENO , &fds)) { + char *inbuf=NULL; + size_t inlen=0; + inlen = getline( &inbuf,&inlen, stdin); + if ( inlen > 0 ) { + if ( send(sock, inbuf,inlen, 0) < 0) + break; + } + free(inbuf); + } + } + close(sock); + } + return; +} /* run_telnetclt */ + void poll_telnetcmdq(void *qid, void *arg) { notifiedFIFO_elt_t *msg = pollNotifiedFIFO((notifiedFIFO_t *)qid); @@ -720,10 +785,10 @@ void exec_moduleinit(char *modname) { int add_embeddedmodules(void) { int ret=0; - - for(int i=0; i +#include +#include +#include +#include +#include +#include + + + + +#define TELNETSERVERCODE +#include "telnetsrv.h" + +#include "common/utils/LOG/log.h" +#include "common/config/config_userapi.h" +#include "telnetsrv_measurements.h" +#include "telnetsrv_ltemeasur_def.h" +#include "telnetsrv_cpumeasur_def.h" +#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h" +#include "openair1/PHY/phy_extern_nr_ue.h" + +void measurcmd_display_macstats(telnet_printfunc_t prnt); +void measurcmd_display_macstats_ue(telnet_printfunc_t prnt); +void measurcmd_display_rlcstats(telnet_printfunc_t prnt); +void measurcmd_display_phycpu(telnet_printfunc_t prnt); +void measurcmd_display_maccpu(telnet_printfunc_t prnt); +void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt); + + +static telnet_measurgroupdef_t nrUEmeasurgroups[] = { +// {"ue", GROUP_LTESTATS,0, measurcmd_display_macstats, {NULL}}, +// {"rlc", GROUP_LTESTATS,0, measurcmd_display_rlcstats, {NULL}}, + {"phycpu",GROUP_CPUSTATS,0, measurcmd_display_phycpu, {NULL}}, +// {"maccpu",GROUP_CPUSTATS,0, measurcmd_display_maccpu, {NULL}}, +// {"pdcpcpu",GROUP_CPUSTATS,0, measurcmd_display_pdcpcpu, {NULL}}, +}; +#define TELNET_NUM_NRUEMEASURGROUPS (sizeof(nrUEmeasurgroups)/sizeof(telnet_measurgroupdef_t)) + + +static double cpufreq; + + +#define HDR "---------------------------------" + + +int get_measurgroups(telnet_measurgroupdef_t **measurgroups) { + *measurgroups = nrUEmeasurgroups; + return TELNET_NUM_NRUEMEASURGROUPS; +} + + +void measurcmd_display_phycpu(telnet_printfunc_t prnt) { + PHY_VARS_NR_UE *UE = PHY_vars_UE_g[0][0]; + telnet_cpumeasurdef_t cpumeasur[]=CPU_PHYNRUE_MEASURE; + prnt("%s cpu (%1.1g GHz) measurements: PHY (cpustats %s) %s\n",HDR,cpufreq, + PRINT_CPUMEAS_STATE,HDR); + measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t)); +} +/* +void measurcmd_display_maccpu(telnet_printfunc_t prnt) { + eNB_MAC_INST *macvars = RC.mac[eNB_id]; + telnet_cpumeasurdef_t cpumeasur[]=CPU_MACENB_MEASURE; + prnt("%s cpu (%1.1g GHz) measurements: MAC (cpustats %s) %s\n",HDR,cpufreq, + PRINT_CPUMEAS_STATE,HDR); + measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t)); +} + +void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt) { + pdcp_stats_t *pdcpvars = &(eNB_pdcp_stats[eNB_id]); + telnet_cpumeasurdef_t cpumeasur[]=CPU_PDCPENB_MEASURE; + prnt("%s cpu (%1.1g GHz) measurements: PDCP (cpustats %s) %s \n",HDR,cpufreq, + PRINT_CPUMEAS_STATE,HDR); + measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t)); +} +//---------------------------------------------------------------------------------------------------- + + +void measurcmd_display_macstats_ue(telnet_printfunc_t prnt) { + UE_info_t *UE_info = &(RC.mac[eNB_id]->UE_info); + + for (int UE_id=UE_info->list.head; UE_id>=0; UE_id=UE_info->list.next[UE_id]) { + for (int i=0; inumactiveCCs[UE_id]; i++) { + int CC_id = UE_info->ordered_CCids[i][UE_id]; + prnt("%s UE %i Id %i CCid %i %s\n",HDR,i,UE_id,CC_id,HDR); + eNB_UE_STATS *macuestatptr = &(UE_info->eNB_UE_stats[CC_id][UE_id]); + telnet_ltemeasurdef_t statsptr[]=LTEMAC_UEMEASURE; + measurcmd_display_measures(prnt, statsptr, sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t)); + } + } +} // measurcmd_display_macstats_ue + +void measurcmd_display_macstats(telnet_printfunc_t prnt) { + for (int CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) { + eNB_STATS *macstatptr=&(RC.mac[eNB_id]->eNB_stats[CC_id]); + telnet_ltemeasurdef_t statsptr[]=LTEMAC_MEASURE; + prnt("%s eNB %i mac stats CC %i frame %u %s\n", + HDR, eNB_id, CC_id, RC.mac[eNB_id]->frame,HDR); + measurcmd_display_measures(prnt,statsptr,sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t)); + } +} // measurcmd_display_macstats + + +void measurcmd_display_one_rlcstat(telnet_printfunc_t prnt, int UE_id, telnet_ltemeasurdef_t *statsptr, int num_rlcmeasure, unsigned int *rlcstats, + char *rbid_str, protocol_ctxt_t *ctxt, const srb_flag_t srb_flagP, const rb_id_t rb_idP) + +{ + int rlc_status = rlc_stat_req(ctxt,srb_flagP,rb_idP, + rlcstats, rlcstats+1, rlcstats+2, rlcstats+3, rlcstats+4, rlcstats+5, + rlcstats+6, rlcstats+7, rlcstats+8, rlcstats+9, rlcstats+10, rlcstats+11, + rlcstats+12, rlcstats+13, rlcstats+14, rlcstats+15, rlcstats+16, rlcstats+17, + rlcstats+18, rlcstats+19, rlcstats+20, rlcstats+21, rlcstats+22, rlcstats+23, + rlcstats+24, rlcstats+25, rlcstats+26, rlcstats+27); + + if (rlc_status == RLC_OP_STATUS_OK) { + prnt("%s UE %i RLC %s mode %s %s\n",HDR,UE_id, rbid_str, + (rlcstats[0]==RLC_MODE_AM)? "AM": (rlcstats[0]==RLC_MODE_UM)?"UM":"NONE",HDR); + measurcmd_display_measures(prnt, statsptr, num_rlcmeasure); + } +} // status measurcmd_rlc_stat_req + + +void measurcmd_display_rlcstats(telnet_printfunc_t prnt) { + protocol_ctxt_t ctxt; + UE_info_t *UE_info = &(RC.mac[eNB_id]->UE_info); + telnet_ltemeasurdef_t statsptr[]=LTE_RLCMEASURE; + int num_rlcmeasure = sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t ); + unsigned int *rlcstats = malloc(num_rlcmeasure*sizeof(unsigned int)); + eNB_MAC_INST *eNB = RC.mac[eNB_id]; + + for(int i=0; i list.head; UE_id>=0; UE_id=UE_info->list.next[UE_id]) { +#define NB_eNB_INST 1 + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,eNB_id, ENB_FLAG_YES,UE_info->eNB_UE_stats[0][UE_id].crnti, + eNB->frame,eNB->subframe,eNB_id); + measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DCCH", &ctxt, SRB_FLAG_YES, DCCH); + measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DTCH", &ctxt, SRB_FLAG_NO, DTCH-2); + } +} // measurcmd_display_macstats_ue + +*/ + + diff --git a/common/utils/telnetsrv/telnetsrv_CMakeLists.txt b/common/utils/telnetsrv/telnetsrv_CMakeLists.txt index 519a1a72ff..2713c71cc0 100644 --- a/common/utils/telnetsrv/telnetsrv_CMakeLists.txt +++ b/common/utils/telnetsrv/telnetsrv_CMakeLists.txt @@ -8,9 +8,9 @@ set(TELNETSRV_SOURCE ) add_library(telnetsrv MODULE ${TELNETSRV_SOURCE} ) -target_link_libraries(telnetsrv PRIVATE history) +target_link_libraries(telnetsrv PRIVATE history ncurses form ) -foreach(TELNETLIB enb gnb 4gUE 5gUE) +foreach(TELNETLIB enb gnb 4Gue 5Gue) set(TELNETLIB_SRCS "") foreach(TELNETLIB_ASRC measurements phycmd) set(TELNETLIB_SRC ${OPENAIR_DIR}/common/utils/telnetsrv/telnetsrv_${TELNETLIB}_${TELNETLIB_ASRC}.c) @@ -32,4 +32,4 @@ install(TARGETS telnetsrv DESTINATION bin) if (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build") install(TARGETS telnetsrv DESTINATION ${OPENAIR_BUILD_DIR}/ran_build/build) -endif (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build") \ No newline at end of file +endif (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build") diff --git a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h index 7a45b351f3..a275272e80 100644 --- a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h +++ b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h @@ -24,8 +24,8 @@ * \ strucures arrays which are then used by the display functions * \ in telnetsrv_measurements.c. * \author Francois TABURET - * \date 2019 - * \version 0.1 + * \date 2021 + * \version 0.2 * \company NOKIA BellLabs France * \email: francois.taburet@nokia-bell-labs.com * \note @@ -37,67 +37,119 @@ #define CPU_PHYENB_MEASURE \ { \ - {"phy_proc_tx", &(phyvars->phy_proc_tx),0},\ - {"phy_proc_rx", &(phyvars->phy_proc_rx),0},\ - {"rx_prach", &(phyvars->rx_prach),0},\ - {"ofdm_mod", &(phyvars->ofdm_mod_stats),0},\ - {"dlsch_common_and_dci", &(phyvars->dlsch_common_and_dci),0},\ - {"dlsch_ue_specific", &(phyvars->dlsch_ue_specific),0},\ - {"dlsch_encoding", &(phyvars->dlsch_encoding_stats),0},\ - {"dlsch_modulation", &(phyvars->dlsch_modulation_stats),0},\ - {"dlsch_scrambling", &(phyvars->dlsch_scrambling_stats),0},\ - {"dlsch_rate_matching", &(phyvars->dlsch_rate_matching_stats),0},\ - {"dlsch_turbo_encod_prep", &(phyvars->dlsch_turbo_encoding_preperation_stats),0},\ - {"dlsch_turbo_encod_segm", &(phyvars->dlsch_turbo_encoding_segmentation_stats),0},\ - {"dlsch_turbo_encod", &(phyvars->dlsch_turbo_encoding_stats),0},\ - {"dlsch_turbo_encod_waiting", &(phyvars->dlsch_turbo_encoding_waiting_stats),0},\ - {"dlsch_turbo_encod_signal", &(phyvars->dlsch_turbo_encoding_signal_stats),0},\ - {"dlsch_turbo_encod_main", &(phyvars->dlsch_turbo_encoding_main_stats),0},\ - {"dlsch_turbo_encod_wakeup0", &(phyvars->dlsch_turbo_encoding_wakeup_stats0),0},\ - {"dlsch_turbo_encod_wakeup1", &(phyvars->dlsch_turbo_encoding_wakeup_stats1),0},\ - {"dlsch_interleaving", &(phyvars->dlsch_interleaving_stats),0},\ - {"rx_dft", &(phyvars->rx_dft_stats),0},\ - {"ulsch_channel_estimation", &(phyvars->ulsch_channel_estimation_stats),0},\ - {"ulsch_freq_offset_estimation", &(phyvars->ulsch_freq_offset_estimation_stats),0},\ - {"ulsch_decoding", &(phyvars->ulsch_decoding_stats),0},\ - {"ulsch_demodulation", &(phyvars->ulsch_demodulation_stats),0},\ - {"ulsch_rate_unmatching", &(phyvars->ulsch_rate_unmatching_stats),0},\ - {"ulsch_turbo_decoding", &(phyvars->ulsch_turbo_decoding_stats),0},\ - {"ulsch_deinterleaving", &(phyvars->ulsch_deinterleaving_stats),0},\ - {"ulsch_demultiplexing", &(phyvars->ulsch_demultiplexing_stats),0},\ - {"ulsch_llr", &(phyvars->ulsch_llr_stats),0},\ - {"ulsch_tc_init", &(phyvars->ulsch_tc_init_stats),0},\ - {"ulsch_tc_alpha", &(phyvars->ulsch_tc_alpha_stats),0},\ - {"ulsch_tc_beta", &(phyvars->ulsch_tc_beta_stats),0},\ - {"ulsch_tc_gamma", &(phyvars->ulsch_tc_gamma_stats),0},\ - {"ulsch_tc_ext", &(phyvars->ulsch_tc_ext_stats),0},\ - {"ulsch_tc_intl1", &(phyvars->ulsch_tc_intl1_stats),0},\ - {"ulsch_tc_intl2", &(phyvars->ulsch_tc_intl2_stats),0},\ + {"phy_proc_tx", &(phyvars->phy_proc_tx),0,1},\ + {"phy_proc_rx", &(phyvars->phy_proc_rx),0,1},\ + {"rx_prach", &(phyvars->rx_prach),0,1},\ + {"ofdm_mod", &(phyvars->ofdm_mod_stats),0,1},\ + {"dlsch_common_and_dci", &(phyvars->dlsch_common_and_dci),0,1},\ + {"dlsch_ue_specific", &(phyvars->dlsch_ue_specific),0,1},\ + {"dlsch_encoding", &(phyvars->dlsch_encoding_stats),0,1},\ + {"dlsch_modulation", &(phyvars->dlsch_modulation_stats),0,1},\ + {"dlsch_scrambling", &(phyvars->dlsch_scrambling_stats),0,1},\ + {"dlsch_rate_matching", &(phyvars->dlsch_rate_matching_stats),0,1},\ + {"dlsch_turbo_encod_prep", &(phyvars->dlsch_turbo_encoding_preperation_stats),0,1},\ + {"dlsch_turbo_encod_segm", &(phyvars->dlsch_turbo_encoding_segmentation_stats),0,1},\ + {"dlsch_turbo_encod", &(phyvars->dlsch_turbo_encoding_stats),0,1},\ + {"dlsch_turbo_encod_waiting", &(phyvars->dlsch_turbo_encoding_waiting_stats),0,1},\ + {"dlsch_turbo_encod_signal", &(phyvars->dlsch_turbo_encoding_signal_stats),0,1},\ + {"dlsch_turbo_encod_main", &(phyvars->dlsch_turbo_encoding_main_stats),0,1},\ + {"dlsch_turbo_encod_wakeup0", &(phyvars->dlsch_turbo_encoding_wakeup_stats0),0,1},\ + {"dlsch_turbo_encod_wakeup1", &(phyvars->dlsch_turbo_encoding_wakeup_stats1),0,1},\ + {"dlsch_interleaving", &(phyvars->dlsch_interleaving_stats),0,1},\ + {"rx_dft", &(phyvars->rx_dft_stats),0,1},\ + {"ulsch_channel_estimation", &(phyvars->ulsch_channel_estimation_stats),0,1},\ + {"ulsch_freq_offset_estimation", &(phyvars->ulsch_freq_offset_estimation_stats),0,1},\ + {"ulsch_decoding", &(phyvars->ulsch_decoding_stats),0,1},\ + {"ulsch_demodulation", &(phyvars->ulsch_demodulation_stats),0,1},\ + {"ulsch_rate_unmatching", &(phyvars->ulsch_rate_unmatching_stats),0,1},\ + {"ulsch_turbo_decoding", &(phyvars->ulsch_turbo_decoding_stats),0,1},\ + {"ulsch_deinterleaving", &(phyvars->ulsch_deinterleaving_stats),0,1},\ + {"ulsch_demultiplexing", &(phyvars->ulsch_demultiplexing_stats),0,1},\ + {"ulsch_llr", &(phyvars->ulsch_llr_stats),0,1},\ + {"ulsch_tc_init", &(phyvars->ulsch_tc_init_stats),0,1},\ + {"ulsch_tc_alpha", &(phyvars->ulsch_tc_alpha_stats),0,1},\ + {"ulsch_tc_beta", &(phyvars->ulsch_tc_beta_stats),0,1},\ + {"ulsch_tc_gamma", &(phyvars->ulsch_tc_gamma_stats),0,1},\ + {"ulsch_tc_ext", &(phyvars->ulsch_tc_ext_stats),0,1},\ + {"ulsch_tc_intl1", &(phyvars->ulsch_tc_intl1_stats),0,1},\ + {"ulsch_tc_intl2", &(phyvars->ulsch_tc_intl2_stats),0,1},\ } #define CPU_MACENB_MEASURE \ { \ - {"eNB_scheduler", &(macvars->eNB_scheduler),0},\ - {"schedule_si", &(macvars->schedule_si),0},\ - {"schedule_ra", &(macvars->schedule_ra),0},\ - {"schedule_ulsch", &(macvars->schedule_ulsch),0},\ - {"fill_DLSCH_dci", &(macvars->fill_DLSCH_dci),0},\ - {"schedule_dlsch_pre", &(macvars->schedule_dlsch_preprocessor),0},\ - {"schedule_dlsch", &(macvars->schedule_dlsch),0},\ - {"schedule_mch", &(macvars->schedule_mch),0},\ - {"rx_ulsch_sdu", &(macvars->rx_ulsch_sdu),0},\ - {"schedule_pch", &(macvars->schedule_pch),0},\ + {"eNB_scheduler", &(macvars->eNB_scheduler),0,1},\ + {"schedule_si", &(macvars->schedule_si),0,1},\ + {"schedule_ra", &(macvars->schedule_ra),0,1},\ + {"schedule_ulsch", &(macvars->schedule_ulsch),0,1},\ + {"fill_DLSCH_dci", &(macvars->fill_DLSCH_dci),0,1},\ + {"schedule_dlsch_pre", &(macvars->schedule_dlsch_preprocessor),0,1},\ + {"schedule_dlsch", &(macvars->schedule_dlsch),0,1},\ + {"schedule_mch", &(macvars->schedule_mch),0,1},\ + {"rx_ulsch_sdu", &(macvars->rx_ulsch_sdu),0,1},\ + {"schedule_pch", &(macvars->schedule_pch),0,1},\ } #define CPU_PDCPENB_MEASURE \ { \ - {"pdcp_run", &(pdcpvars->pdcp_run),0},\ - {"data_req", &(pdcpvars->data_req),0},\ - {"data_ind", &(pdcpvars->data_ind),0},\ - {"apply_security", &(pdcpvars->apply_security),0},\ - {"validate_security", &(pdcpvars->validate_security),0},\ - {"pdcp_ip", &(pdcpvars->pdcp_ip),0},\ - {"ip_pdcp", &(pdcpvars->ip_pdcp),0},\ + {"pdcp_run", &(pdcpvars->pdcp_run),0,1},\ + {"data_req", &(pdcpvars->data_req),0,1},\ + {"data_ind", &(pdcpvars->data_ind),0,1},\ + {"apply_security", &(pdcpvars->apply_security),0,1},\ + {"validate_security", &(pdcpvars->validate_security),0,1},\ + {"pdcp_ip", &(pdcpvars->pdcp_ip),0,1},\ + {"ip_pdcp", &(pdcpvars->ip_pdcp),0,1},\ } +/* from openair1/PHY/defs_nr_UE.h */ +#define CPU_PHYNRUE_MEASURE \ +{ \ + {"phy_proc", &(UE->phy_proc[0]),0,RX_NB_TH},\ + {"phy_proc_rx", &(UE-> phy_proc_rx[0]),0,RX_NB_TH},\ + {"phy_proc_tx", &(UE->phy_proc_tx),0,1},\ + {"ofdm_mod_stats", &(UE->ofdm_mod_stats),0,1},\ + {"ulsch_encoding_stats", &(UE->ulsch_encoding_stats),0,1},\ + {"ulsch_modulation_stats", &(UE->ulsch_modulation_stats),0,1},\ + {"ulsch_segmentation_stats", &(UE->ulsch_segmentation_stats),0,1},\ + {"ulsch_rate_matching_stats", &(UE->ulsch_rate_matching_stats),0,1},\ + {"ulsch_turbo_encoding_stats", &(UE->ulsch_turbo_encoding_stats),0,1},\ + {"ulsch_interleaving_stats", &(UE->ulsch_interleaving_stats),0,1},\ + {"ulsch_multiplexing_stats", &(UE->ulsch_multiplexing_stats),0,1},\ + {"generic_stat", &(UE->generic_stat),0,1},\ + {"generic_stat_bis", &(UE->generic_stat_bis[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ + {"ofdm_demod_stats", &(UE->ofdm_demod_stats),0,1},\ + {"dlsch_rx_pdcch_stats", &(UE->dlsch_rx_pdcch_stats),0,1},\ + {"rx_dft_stats", &(UE->rx_dft_stats),0,1},\ + {"dlsch_c...timation_stats", &(UE->dlsch_channel_estimation_stats),0,1},\ + {"dlsch_f...timation_stats", &(UE->dlsch_freq_offset_estimation_stats),0,1},\ + {"dlsch_demodulation_stats", &(UE->dlsch_demodulation_stats),0,1},\ + {"dlsch_rate_unmatching_stats", &(UE->dlsch_rate_unmatching_stats),0,1},\ + {"dlsch_turbo_decoding_stats", &(UE->dlsch_turbo_decoding_stats),0,1},\ + {"dlsch_deinterleaving_stats", &(UE->dlsch_deinterleaving_stats),0,1},\ + {"dlsch_llr_stats", &(UE->dlsch_llr_stats),0,1},\ + {"dlsch_unscrambling_stats", &(UE->dlsch_unscrambling_stats),0,1},\ + {"dlsch_rate_matching_stats", &(UE->dlsch_rate_matching_stats),0,1},\ + {"dlsch_turbo_encoding_stats", &(UE->dlsch_turbo_encoding_stats),0,1},\ + {"dlsch_interleaving_stats", &(UE->dlsch_interleaving_stats),0,1},\ + {"dlsch_tc_init_stats", &(UE->dlsch_tc_init_stats),0,1},\ + {"dlsch_tc_alpha_stats", &(UE->dlsch_tc_alpha_stats),0,1},\ + {"dlsch_tc_beta_stats", &(UE->dlsch_tc_beta_stats),0,1},\ + {"dlsch_tc_gamma_stats", &(UE->dlsch_tc_gamma_stats),0,1},\ + {"dlsch_tc_ext_stats", &(UE->dlsch_tc_ext_stats),0,1},\ + {"dlsch_tc_intl1_stats", &(UE->dlsch_tc_intl1_stats),0,1},\ + {"dlsch_tc_intl2_stats", &(UE->dlsch_tc_intl2_stats),0,1},\ + {"tx_prach", &(UE->tx_prach),0,1},\ + {"dlsch_encoding_SIC_stats", &(UE->dlsch_encoding_SIC_stats),0,1},\ + {"dlsch_scrambling_SIC_stats", &(UE->dlsch_scrambling_SIC_stats),0,1},\ + {"dlsch_modulation_SIC_stats", &(UE->dlsch_modulation_SIC_stats),0,1},\ + {"dlsch...ping_unit_SIC_stats", &(UE->dlsch_llr_stripping_unit_SIC_stats),0,1},\ + {"dlsch_unscrambling_SIC_stats", &(UE->dlsch_unscrambling_SIC_stats),0,1},\ + {"ue_front_end_stat", &(UE->ue_front_end_stat[0]),0,RX_NB_TH},\ + {"ue_front_end_per_slot_stat", &(UE->ue_front_end_per_slot_stat[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ + {"pdcch_procedures_stat", &(UE->pdcch_procedures_stat[0]),0,RX_NB_TH},\ + {"pdsch_procedures_stat", &(UE->pdsch_procedures_stat[0]),0,RX_NB_TH},\ + {"pdsch_procedures_per_slot_stat", &(UE->pdsch_procedures_per_slot_stat[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ + {"dlsch_procedures_stat", &(UE->dlsch_procedures_stat[0]),0,RX_NB_TH},\ + {"dlsch_decoding_stats", &(UE->dlsch_decoding_stats[0]),0,RX_NB_TH},\ + {"dlsch_llr_stats_para", &(UE->dlsch_llr_stats_parallelization[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ +} #endif diff --git a/common/utils/telnetsrv/telnetsrv_measurements.c b/common/utils/telnetsrv/telnetsrv_measurements.c index 4a11e7c2dd..786cbd094c 100644 --- a/common/utils/telnetsrv/telnetsrv_measurements.c +++ b/common/utils/telnetsrv/telnetsrv_measurements.c @@ -64,13 +64,30 @@ void measurcmd_display_groups(telnet_printfunc_t prnt,telnet_measurgroupdef_t *m } /* measurcmd_display_groups */ /*----------------------------------------------------------------------------------------------------*/ /* cpu measurements functions */ -void measurcmd_display_cpumeasures(telnet_printfunc_t prnt, telnet_cpumeasurdef_t *cpumeasure, int cpumeasure_size) { - for (int i=0; istatname, - ((cpumeasure+i)->astatptr->trials!=0)?(((cpumeasure+i)->astatptr->diff)/((cpumeasure+i)->astatptr->trials))/cpufreq/1000:0, - (cpumeasure+i)->astatptr->trials, ((i%2)==1)?"|\n":" | " ); - } + +static char *stridx(int max,int i, char *buff) { + if (max>1) + sprintf(buff,"[%d]",i); + else + sprintf(buff," "); + return buff; + +} +void measurcmd_display_cpumeasures(telnet_printfunc_t prnt, telnet_cpumeasurdef_t *cpumeasure, int cpumeasure_size) { + int p=0; + char stridx1[16]; + char stridx2[16]; + for (int i=0; istatname, + stridx(cpumeasure[i].num_occur1,o1,stridx1),stridx(cpumeasure[i].num_occur2,o2,stridx2), + ((cpumeasure+i+o1+o2)->astatptr->trials!=0)?(((cpumeasure+i+o1+o2)->astatptr->diff)/((cpumeasure+i+o1+o2)->astatptr->trials))/cpufreq/1000:0, + (cpumeasure+i+o1+o2)->astatptr->trials, ((p%2)==1)?"|\n":" | " ); + p++; + } prnt("\n\n"); } /* measurcmd_display_measures */ @@ -137,11 +154,17 @@ int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt) { } telnet_measurgroupdef_t *measurgroups; int num_measurgroups = fptr( &measurgroups); - + int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2); if (s>0) { - if ( strcmp(subcmd,"groups") == 0) { + if ( strcmp(subcmd,"inq") == 0) { + notifiedFIFO_elt_t *msg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL); + time_stats_msg_t *msgdata=NotifiedFifoData(msg); + msgdata->msgid = TIMESTAT_MSGID_DISPLAY; + msgdata->displayFunc = prnt; + pushNotifiedFIFO(&measur_fifo, msg); + } else if ( strcmp(subcmd,"groups") == 0){ measurcmd_display_groups(prnt,measurgroups,num_measurgroups); badcmd=0; } else { @@ -182,13 +205,13 @@ int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) { int badcmd=1; if (debug > 0) - prnt(" measurcmd_show received %s\n",buf); + prnt(" measurcmd_cpustats received %s\n",buf); int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2); if (s>0) { if ( strcmp(subcmd,"enable") == 0) { - cpumeas(CPUMEAS_ENABLE); + badcmd=0; } else if ( strcmp(subcmd,"disable") == 0) { cpumeas(CPUMEAS_DISABLE); @@ -203,6 +226,64 @@ int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) { free(subcmd); return CMDSTATUS_FOUND; } + +void measurcmd_async_help(telnet_printfunc_t prnt) { +} + +int measurcmd_async(char *buf, int debug, telnet_printfunc_t prnt) { + char *subcmd=NULL; + int idx1, idx2; + int okcmd=0; + + if (buf == NULL) { + measurcmd_async_help(prnt); + return CMDSTATUS_FOUND; + } + if (debug > 0) + prnt(" measurcmd_async received %s\n",buf); + + + int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2); + + if (s==1) { + if ( strcmp(subcmd,"enable") == 0) { + init_meas(); + okcmd=1; + } else if ( strcmp(subcmd,"disable") == 0) { + end_meas(); + okcmd=1; + } + } else if ( s == 3 ) { + int msgid; + if ( strcmp(subcmd,"enable") == 0) { + msgid = TIMESTAT_MSGID_ENABLE; + okcmd=1; + } else if ( strcmp(subcmd,"disable") == 0) { + msgid = TIMESTAT_MSGID_DISABLE; + okcmd=1; + } else if ( strcmp(subcmd,"display") == 0) { + msgid = TIMESTAT_MSGID_DISPLAY; + okcmd=1; + } + if (okcmd) { + notifiedFIFO_elt_t *nfe = newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL); + time_stats_msg_t *msg = (time_stats_msg_t *)NotifiedFifoData(nfe); + msg->msgid = msgid ; + msg->displayFunc = prnt; + for(int i=idx1; itimestat_id =i; + pushNotifiedFIFO(&measur_fifo, nfe); + } + } + } + + if (!(okcmd)) { + prnt("Unknown command: %s\n",buf); + } + + free(subcmd); + return CMDSTATUS_FOUND; +} /*-------------------------------------------------------------------------------------*/ /* function called at telnet server init to add the measur command */ diff --git a/common/utils/telnetsrv/telnetsrv_measurements.h b/common/utils/telnetsrv/telnetsrv_measurements.h index 08136df0fd..99ae695f41 100644 --- a/common/utils/telnetsrv/telnetsrv_measurements.h +++ b/common/utils/telnetsrv/telnetsrv_measurements.h @@ -49,6 +49,9 @@ typedef struct cpumeasurdef { char statname[TELNET_MAXMEASURNAME_LEN]; time_stats_t *astatptr; unsigned int statemask; + uint8_t num_occur1; + uint8_t num_occur2; + uint8_t num_occur3; } telnet_cpumeasurdef_t; typedef struct ltemeasurdef { @@ -60,6 +63,7 @@ typedef struct ltemeasurdef { #define GROUP_LTESTATS 0 #define GROUP_CPUSTATS 1 + typedef void(*measur_dislayfunc_t)(telnet_printfunc_t prnt); typedef struct mesurgroupdef { char groupname[TELNET_MAXMEASURNAME_LEN]; @@ -79,9 +83,11 @@ typedef struct mesurgroupdef { #ifdef TELNETSRV_MEASURMENTS_MAIN int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt); int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt); +int measurcmd_async(char *buf, int debug, telnet_printfunc_t prnt); telnetshell_cmddef_t measur_cmdarray[] = { - {"show", "groups | " , measurcmd_show}, + {"show", "groups | | inq" , measurcmd_show}, {"cpustats","[enable | disable]",measurcmd_cpustats}, + {"async","[enable | disable]",measurcmd_async}, {"","",NULL} }; diff --git a/doc/BUILD.md b/doc/BUILD.md index 166563877e..40b63ac697 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -88,6 +88,21 @@ You can build any oai softmodem executable separately, you may not need all of t After completing the build, the binaries are available in the `cmake_targets/ran_build/build` directory. A copy is also available in the `target/bin` directory, with all binaries suffixed by the 3GPP release number, today .Rel15. +When installing the pre-requisites, especially the `UHD` driver, you can now specify if you want to install from source or not. + +- For `fedora`-based OS, it was already the case all the time. But now you can specify which version to install. +- For `ubuntu` OS, the Ettus PPA currently installs the following versions: + * `Ubuntu16.04`: --> version `3.15.0.0` + * `Ubuntu18.04`: --> version `4.1.0.0` + +```bash +export BUILD_UHD_FROM_SOURCE=True +export UHD_VERSION=3.15.0.0 +./build_oai -I -w USRP +``` + +The `UHD_VERSION` env variable `SHALL` be a valid tag (minus `v`) from the `https://github.com/EttusResearch/uhd.git` repository. + ## Issue when building `nasmeh` module ## A lot of users and contributors have faced the issue: `nasmesh` module does not build. diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index dc7a982310..d063afd5d9 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -203,10 +203,7 @@ UE on machine 2: - - - - +[Selecting an alternative ldpc implementation at run time](../openair1/PHY/CODING/DOC/LDPCImplementation.md) [oai wiki home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/doc/testing_gnb_w_cots_ue_resources/gnb.conf b/doc/testing_gnb_w_cots_ue_resources/gnb.conf index c4a8d512b8..97935f92ee 100755 --- a/doc/testing_gnb_w_cots_ue_resources/gnb.conf +++ b/doc/testing_gnb_w_cots_ue_resources/gnb.conf @@ -275,6 +275,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/docker/Dockerfile.eNB.rhel8.2 b/docker/Dockerfile.eNB.rhel8.2 index 90c807fc0e..0522271df0 100644 --- a/docker/Dockerfile.eNB.rhel8.2 +++ b/docker/Dockerfile.eNB.rhel8.2 @@ -41,17 +41,23 @@ RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-enb +ENV TZ=Europe/Paris RUN yum update -y && \ yum install -y --enablerepo="ubi-8-codeready-builder" \ lksctp-tools \ nettle \ + tzdata \ procps-ng \ atlas \ + python3 \ + python3-pip \ net-tools \ iputils \ iproute \ libyaml && \ + pip3 install six && \ + pip3 install requests && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf @@ -78,6 +84,8 @@ COPY --from=enb-build /lib64/libconfig.so.9 /lib64 COPY --from=enb-build /lib64/libblas.so.3 /lib64 COPY --from=enb-build /lib64/liblapack.so.3 /lib64 COPY --from=enb-build /lib64/liblapacke.so.3 /lib64 + +# Now we are copying from builder-image the UHD files. COPY --from=enb-build /lib64/libboost_chrono.so.1.66.0 /lib64 COPY --from=enb-build /lib64/libboost_date_time.so.1.66.0 /lib64 COPY --from=enb-build /lib64/libboost_filesystem.so.1.66.0 /lib64 @@ -88,7 +96,14 @@ COPY --from=enb-build /lib64/libboost_system.so.1.66.0 /lib64 COPY --from=enb-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 COPY --from=enb-build /lib64/libboost_atomic.so.1.66.0 /lib64 COPY --from=enb-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=enb-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 +COPY --from=enb-build /lib64/libboost_regex.so.1.66.0 /lib64 + +COPY --from=enb-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=enb-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=enb-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin + +WORKDIR /usr/local/share/uhd/rfnoc +COPY --from=enb-build /usr/local/share/uhd/rfnoc/ . RUN ldconfig diff --git a/docker/Dockerfile.eNB.ubuntu18 b/docker/Dockerfile.eNB.ubuntu18 index c4393dc78e..cf748784e5 100644 --- a/docker/Dockerfile.eNB.ubuntu18 +++ b/docker/Dockerfile.eNB.ubuntu18 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS enb-build +FROM ran-build:latest AS enb-build RUN rm -Rf /oai-ran WORKDIR /oai-ran @@ -42,8 +42,7 @@ RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters #start from scratch for target executable FROM ubuntu:bionic as oai-enb ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=Europe -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +ENV TZ=Europe/Paris RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ @@ -60,16 +59,12 @@ RUN apt-get update && \ iputils-ping \ iproute2 \ iperf \ - libyaml-0-2 && \ - # Install UHD driver from ettus ppa - # At time of writing, it is 3.14 - add-apt-repository ppa:ettusresearch/uhd --yes && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ python \ + python3 \ + python3-six \ + python3-requests \ libusb-1.0-0 \ - libuhd003 \ - uhd-host && \ + libyaml-0-2 && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-enb/bin @@ -90,6 +85,17 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/ RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" COPY --from=enb-build /usr/local/lib/libprotobuf-c.so.1 . +# Now we are copying from builder-image the UHD files. +COPY --from=enb-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=enb-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=enb-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin +WORKDIR /usr/lib/x86_64-linux-gnu +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . +COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . RUN ldconfig diff --git a/docker/Dockerfile.gNB.rhel8.2 b/docker/Dockerfile.gNB.rhel8.2 index 9ee0bf9ae9..b34a9d242d 100644 --- a/docker/Dockerfile.gNB.rhel8.2 +++ b/docker/Dockerfile.gNB.rhel8.2 @@ -41,6 +41,7 @@ RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/gnb_parameters #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-gnb +ENV TZ=Europe/Paris RUN yum repolist --disablerepo=* && \ yum update -y && \ @@ -51,9 +52,14 @@ RUN yum repolist --disablerepo=* && \ atlas \ lksctp-tools \ nettle \ + tzdata \ + python3 \ + python3-pip \ net-tools \ iputils \ libyaml && \ + pip3 install six && \ + pip3 install requests && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf @@ -84,6 +90,8 @@ COPY --from=gnb-build /lib64/libforms.so.2 /lib64 COPY --from=gnb-build /lib64/libblas.so.3 /lib64 COPY --from=gnb-build /lib64/liblapack.so.3 /lib64 COPY --from=gnb-build /lib64/liblapacke.so.3 /lib64 + +# Now we are copying from builder-image the UHD files. COPY --from=gnb-build /lib64/libboost_chrono.so.1.66.0 /lib64 COPY --from=gnb-build /lib64/libboost_date_time.so.1.66.0 /lib64 COPY --from=gnb-build /lib64/libboost_filesystem.so.1.66.0 /lib64 @@ -94,7 +102,14 @@ COPY --from=gnb-build /lib64/libboost_system.so.1.66.0 /lib64 COPY --from=gnb-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 COPY --from=gnb-build /lib64/libboost_atomic.so.1.66.0 /lib64 COPY --from=gnb-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=gnb-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 +COPY --from=gnb-build /lib64/libboost_regex.so.1.66.0 /lib64 + +COPY --from=gnb-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=gnb-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=gnb-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin + +WORKDIR /usr/local/share/uhd/rfnoc +COPY --from=gnb-build /usr/local/share/uhd/rfnoc/ . RUN ldconfig diff --git a/docker/Dockerfile.gNB.ubuntu18 b/docker/Dockerfile.gNB.ubuntu18 index 990c4363e5..cfd9d82144 100644 --- a/docker/Dockerfile.gNB.ubuntu18 +++ b/docker/Dockerfile.gNB.ubuntu18 @@ -59,16 +59,12 @@ RUN apt-get update && \ net-tools \ iproute2 \ iputils-ping \ - libyaml-0-2 && \ - # Install UHD driver from ettus ppa - # At time of writing, it is 3.14 - add-apt-repository ppa:ettusresearch/uhd --yes && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ python \ + python3 \ + python3-six \ + python3-requests \ libusb-1.0-0 \ - libuhd003 \ - uhd-host && \ + libyaml-0-2 && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-gnb/bin @@ -93,6 +89,18 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/ RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" COPY --from=gnb-build /usr/local/lib/libprotobuf-c.so.1 . +# Now we are copying from builder-image the UHD files. +COPY --from=gnb-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=gnb-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=gnb-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin +WORKDIR /usr/lib/x86_64-linux-gnu +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . +COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . + RUN ldconfig # Copy the relevant configuration files for gNB diff --git a/docker/Dockerfile.lteRU.rhel8.2 b/docker/Dockerfile.lteRU.rhel8.2 index 314c01dff3..7e2a054a12 100644 --- a/docker/Dockerfile.lteRU.rhel8.2 +++ b/docker/Dockerfile.lteRU.rhel8.2 @@ -48,9 +48,13 @@ RUN yum update -y && \ tzdata \ procps-ng \ atlas \ + python3 \ + python3-pip \ net-tools \ iputils \ iproute && \ + pip3 install six && \ + pip3 install requests && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf @@ -66,11 +70,12 @@ COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . -# Copying from the ran-build image the USRP needed packages COPY --from=ru-build /lib64/libconfig.so.9 /lib64 COPY --from=ru-build /lib64/libblas.so.3 /lib64 COPY --from=ru-build /lib64/liblapack.so.3 /lib64 COPY --from=ru-build /lib64/liblapacke.so.3 /lib64 + +# Copying from the ran-build image the USRP needed packages COPY --from=ru-build /lib64/libboost_chrono.so.1.66.0 /lib64 COPY --from=ru-build /lib64/libboost_date_time.so.1.66.0 /lib64 COPY --from=ru-build /lib64/libboost_filesystem.so.1.66.0 /lib64 @@ -81,7 +86,14 @@ COPY --from=ru-build /lib64/libboost_system.so.1.66.0 /lib64 COPY --from=ru-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 COPY --from=ru-build /lib64/libboost_atomic.so.1.66.0 /lib64 COPY --from=ru-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=ru-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 +COPY --from=ru-build /lib64/libboost_regex.so.1.66.0 /lib64 + +COPY --from=ru-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=ru-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=ru-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin + +WORKDIR /usr/local/share/uhd/rfnoc +COPY --from=ru-build /usr/local/share/uhd/rfnoc/ . RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ diff --git a/docker/Dockerfile.lteRU.ubuntu18 b/docker/Dockerfile.lteRU.ubuntu18 index fa99827d94..eafb8fa8af 100644 --- a/docker/Dockerfile.lteRU.ubuntu18 +++ b/docker/Dockerfile.lteRU.ubuntu18 @@ -54,17 +54,13 @@ RUN apt-get update && \ libatlas3-base \ libconfig9 \ net-tools \ + python \ + python3 \ + python3-six \ + python3-requests \ + libusb-1.0-0 \ iputils-ping \ iproute2 && \ - # Install UHD driver from ettus ppa - # At time of writing, it is 3.14 - add-apt-repository ppa:ettusresearch/uhd --yes && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ - python \ - libusb-1.0-0 \ - libuhd003 \ - uhd-host && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-lte-ru/bin @@ -78,6 +74,19 @@ COPY --from=ru-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . + +# Now we are copying from builder-image the UHD files. +COPY --from=ru-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=ru-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=ru-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin +WORKDIR /usr/lib/x86_64-linux-gnu +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . +COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . + RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" && \ diff --git a/docker/Dockerfile.lteUE.rhel8.2 b/docker/Dockerfile.lteUE.rhel8.2 index 936780297a..a6814be136 100644 --- a/docker/Dockerfile.lteUE.rhel8.2 +++ b/docker/Dockerfile.lteUE.rhel8.2 @@ -42,17 +42,23 @@ RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_paramet #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ue +ENV TZ=Europe/Paris RUN yum update -y && \ yum install -y --enablerepo="ubi-8-codeready-builder" \ lksctp-tools \ procps-ng \ nettle \ + tzdata \ atlas \ + python3 \ + python3-pip \ iproute \ net-tools \ iputils \ libyaml && \ + pip3 install six && \ + pip3 install requests && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf @@ -82,6 +88,8 @@ COPY --from=lte-ue-build /lib64/libconfig.so.9 /lib64 COPY --from=lte-ue-build /lib64/libblas.so.3 /lib64 COPY --from=lte-ue-build /lib64/liblapack.so.3 /lib64 COPY --from=lte-ue-build /lib64/liblapacke.so.3 /lib64 + +# Now we are copying from builder-image the UHD files. COPY --from=lte-ue-build /lib64/libboost_chrono.so.1.66.0 /lib64 COPY --from=lte-ue-build /lib64/libboost_date_time.so.1.66.0 /lib64 COPY --from=lte-ue-build /lib64/libboost_filesystem.so.1.66.0 /lib64 @@ -92,7 +100,14 @@ COPY --from=lte-ue-build /lib64/libboost_system.so.1.66.0 /lib64 COPY --from=lte-ue-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 COPY --from=lte-ue-build /lib64/libboost_atomic.so.1.66.0 /lib64 COPY --from=lte-ue-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=lte-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 +COPY --from=lte-ue-build /lib64/libboost_regex.so.1.66.0 /lib64 + +COPY --from=lte-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=lte-ue-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=lte-ue-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin + +WORKDIR /usr/local/share/uhd/rfnoc +COPY --from=lte-ue-build /usr/local/share/uhd/rfnoc/ . RUN ldconfig diff --git a/docker/Dockerfile.lteUE.ubuntu18 b/docker/Dockerfile.lteUE.ubuntu18 index 34cbe651ad..6d54ab08fc 100644 --- a/docker/Dockerfile.lteUE.ubuntu18 +++ b/docker/Dockerfile.lteUE.ubuntu18 @@ -43,8 +43,7 @@ RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_paramet #start from scratch for target executable FROM ubuntu:bionic as oai-lte-ue ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=Europe -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +ENV TZ=Europe/Paris RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ @@ -58,19 +57,15 @@ RUN apt-get update && \ libconfig9 \ openssl \ net-tools \ + python \ + python3 \ + python3-six \ + python3-requests \ + libusb-1.0-0 \ iputils-ping \ iproute2 \ iperf \ libyaml-0-2 && \ - # Install UHD driver from ettus ppa - # At time of writing, it is 3.14 - add-apt-repository ppa:ettusresearch/uhd --yes && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ - python \ - libusb-1.0-0 \ - libuhd003 \ - uhd-host && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-lte-ue/bin @@ -95,6 +90,18 @@ RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/li COPY --from=lte-ue-build /usr/local/lib/libprotobuf-c.so.1 . +# Now we are copying from builder-image the UHD files. +COPY --from=lte-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=lte-ue-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=lte-ue-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin +WORKDIR /usr/lib/x86_64-linux-gnu +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . +COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . + RUN ldconfig # Copy the relevant configuration files for UE diff --git a/docker/Dockerfile.nrUE.rhel8.2 b/docker/Dockerfile.nrUE.rhel8.2 index 56fc746ade..ec74d11940 100644 --- a/docker/Dockerfile.nrUE.rhel8.2 +++ b/docker/Dockerfile.nrUE.rhel8.2 @@ -51,9 +51,13 @@ RUN yum update -y && \ iputils \ iproute \ atlas \ + python3 \ + python3-pip \ libXpm \ libX11 \ libyaml && \ + pip3 install six && \ + pip3 install requests && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf @@ -87,6 +91,8 @@ COPY --from=nr-ue-build /lib64/libblas.so.3 /lib64 COPY --from=nr-ue-build /lib64/liblapack.so.3 /lib64 COPY --from=nr-ue-build /lib64/liblapacke.so.3 /lib64 COPY --from=nr-ue-build /lib64/libforms.so.2 /lib64 + +# Now we are copying from builder-image the UHD files. COPY --from=nr-ue-build /lib64/libboost_chrono.so.1.66.0 /lib64 COPY --from=nr-ue-build /lib64/libboost_date_time.so.1.66.0 /lib64 COPY --from=nr-ue-build /lib64/libboost_filesystem.so.1.66.0 /lib64 @@ -97,7 +103,15 @@ COPY --from=nr-ue-build /lib64/libboost_system.so.1.66.0 /lib64 COPY --from=nr-ue-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 COPY --from=nr-ue-build /lib64/libboost_atomic.so.1.66.0 /lib64 COPY --from=nr-ue-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=nr-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 +COPY --from=nr-ue-build /lib64/libboost_regex.so.1.66.0 /lib64 + +COPY --from=nr-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=nr-ue-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=nr-ue-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin + +WORKDIR /usr/local/share/uhd/rfnoc +COPY --from=nr-ue-build /usr/local/share/uhd/rfnoc/ . + RUN ldconfig diff --git a/docker/Dockerfile.nrUE.ubuntu18 b/docker/Dockerfile.nrUE.ubuntu18 index fc30af7286..49e3f3213b 100644 --- a/docker/Dockerfile.nrUE.ubuntu18 +++ b/docker/Dockerfile.nrUE.ubuntu18 @@ -55,19 +55,15 @@ RUN apt-get update && \ libconfig9 \ openssl \ net-tools \ + python \ + python3 \ + python3-six \ + python3-requests \ + libusb-1.0-0 \ iputils-ping \ iproute2 \ iperf \ libyaml-0-2 && \ - # Install UHD driver from ettus ppa - # At time of writing, it is 3.14 - add-apt-repository ppa:ettusresearch/uhd --yes && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ - python \ - libusb-1.0-0 \ - libuhd003 \ - uhd-host && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-nr-ue/bin @@ -95,6 +91,18 @@ RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/li COPY --from=nr-ue-build /usr/local/lib/libprotobuf-c.so.1 . +# Now we are copying from builder-image the UHD files. +COPY --from=nr-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=nr-ue-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=nr-ue-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin +WORKDIR /usr/lib/x86_64-linux-gnu +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . +COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . + RUN ldconfig WORKDIR /opt/oai-nr-ue diff --git a/docker/Dockerfile.ran.rhel8.2 b/docker/Dockerfile.ran.rhel8.2 index 3972fd0c35..4d15220ca8 100644 --- a/docker/Dockerfile.ran.rhel8.2 +++ b/docker/Dockerfile.ran.rhel8.2 @@ -28,6 +28,9 @@ FROM registry.access.redhat.com/ubi8/ubi:latest AS ran-build ARG NEEDED_GIT_PROXY +ENV TZ=Europe/Paris +ENV BUILD_UHD_FROM_SOURCE=True +ENV UHD_VERSION=3.15.0.0 COPY tmp/ca/redhat-uep.pem /etc/rhsm/ca COPY tmp/entitlement/*.pem /etc/pki/entitlement diff --git a/docker/Dockerfile.ran.ubuntu18 b/docker/Dockerfile.ran.ubuntu18 index 4b296408fd..3ef81ec030 100644 --- a/docker/Dockerfile.ran.ubuntu18 +++ b/docker/Dockerfile.ran.ubuntu18 @@ -29,8 +29,9 @@ FROM ubuntu:bionic AS ran-build ARG NEEDED_GIT_PROXY ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=Europe -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +ENV TZ=Europe/Paris +ENV BUILD_UHD_FROM_SOURCE=True +ENV UHD_VERSION=3.15.0.0 #install developers pkg/repo RUN apt-get update && \ diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index 2e8886e855..ff92e3c86f 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -46,11 +46,11 @@ done # Load the USRP binaries if [[ -v USE_B2XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx + $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx + $PREFIX/bin/uhd_images_downloader.py -t x3xx elif [[ -v USE_N3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx + $PREFIX/bin/uhd_images_downloader.py -t n3xx fi echo "==================================" diff --git a/docker/scripts/gnb_entrypoint.sh b/docker/scripts/gnb_entrypoint.sh index d59018b56f..36160b136b 100755 --- a/docker/scripts/gnb_entrypoint.sh +++ b/docker/scripts/gnb_entrypoint.sh @@ -39,11 +39,11 @@ done # Load the USRP binaries if [[ -v USE_B2XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx + $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx + $PREFIX/bin/uhd_images_downloader.py -t x3xx elif [[ -v USE_N3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx + $PREFIX/bin/uhd_images_downloader.py -t n3xx fi echo "==================================" diff --git a/docker/scripts/lte_ru_entrypoint.sh b/docker/scripts/lte_ru_entrypoint.sh index f466e25ec2..93122b0d02 100755 --- a/docker/scripts/lte_ru_entrypoint.sh +++ b/docker/scripts/lte_ru_entrypoint.sh @@ -35,11 +35,11 @@ done # Load the USRP binaries if [[ -v USE_B2XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx + $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx + $PREFIX/bin/uhd_images_downloader.py -t x3xx elif [[ -v USE_N3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx + $PREFIX/bin/uhd_images_downloader.py -t n3xx fi echo "==================================" diff --git a/docker/scripts/lte_ue_entrypoint.sh b/docker/scripts/lte_ue_entrypoint.sh index 235128f738..de7ae8b496 100755 --- a/docker/scripts/lte_ue_entrypoint.sh +++ b/docker/scripts/lte_ue_entrypoint.sh @@ -39,11 +39,11 @@ $PREFIX/bin/conf2uedata -c $PREFIX/etc/ue_usim.conf -o $PREFIX # Load the USRP binaries if [[ -v USE_B2XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx + $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx + $PREFIX/bin/uhd_images_downloader.py -t x3xx elif [[ -v USE_N3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx + $PREFIX/bin/uhd_images_downloader.py -t n3xx fi # in case we have conf file, append diff --git a/docker/scripts/nr_ue_entrypoint.sh b/docker/scripts/nr_ue_entrypoint.sh index 691258b8fa..91d25c9e1e 100755 --- a/docker/scripts/nr_ue_entrypoint.sh +++ b/docker/scripts/nr_ue_entrypoint.sh @@ -34,11 +34,11 @@ done # Load the USRP binaries if [[ -v USE_B2XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx + $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx + $PREFIX/bin/uhd_images_downloader.py -t x3xx elif [[ -v USE_N3XX ]]; then - /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx + $PREFIX/bin/uhd_images_downloader.py -t n3xx fi # in case we have conf file, append diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index ce09531e78..95b983190e 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -49,6 +49,7 @@ #include "SCHED_NR/fapi_nr_l1.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/MODULATION/nr_modulation.h" +#include "PHY/NR_TRANSPORT/nr_dlsch.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -88,6 +89,7 @@ #include "executables/softmodem-common.h" #include #include +#include #include //#define DEBUG_THREADS 1 @@ -114,19 +116,36 @@ time_stats_t softmodem_stats_rx_sf; // total rx time void tx_func(void *param) { - processingData_L1_t *info = (processingData_L1_t *) param; + processingData_L1tx_t *info = (processingData_L1tx_t *) param; PHY_VARS_gNB *gNB = info->gNB; - int frame_tx = info->frame_tx; - int slot_tx = info->slot_tx; + int frame_tx = info->frame; + int slot_tx = info->slot; - phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1); + phy_procedures_gNB_TX(info, + frame_tx, + slot_tx, + 1); + info->slot = -1; + //if ((frame_tx&127) == 0) dump_pdsch_stats(fd,gNB); - // start FH TX processing - notifiedFIFO_elt_t *res; + // If the later of the 2 L1 tx thread finishes first, + // we wait for the earlier one to finish and start the RU thread + // to avoid realtime issues with USRP + + // Start RU TX processing. + notifiedFIFO_elt_t *res; res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); processingData_RU_t *syncMsg = (processingData_RU_t *)NotifiedFifoData(res); + LOG_D(PHY,"waiting for previous tx to finish, next slot %d,%d\n",syncMsg->next_slot,slot_tx); + while (syncMsg->next_slot != slot_tx) { + pushNotifiedFIFO(gNB->resp_RU_tx, res); + res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); + syncMsg = (processingData_RU_t *)NotifiedFifoData(res); + } + LOG_D(PHY,"previous tx finished, next slot %d,%d\n",syncMsg->next_slot,slot_tx); syncMsg->frame_tx = frame_tx; syncMsg->slot_tx = slot_tx; + syncMsg->next_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, frame_tx, slot_tx); syncMsg->timestamp_tx = info->timestamp_tx; syncMsg->ru = gNB->RU_list[0]; res->key = slot_tx; @@ -184,7 +203,7 @@ void rx_func(void *param) { int down_removed = 0; int pucch_removed = 0; for (int i = 0; i < rnti_to_remove_count; i++) { - LOG_W(PHY, "to remove rnti %d\n", rnti_to_remove[i]); + LOG_W(NR_PHY, "to remove rnti %d\n", rnti_to_remove[i]); void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); int j; @@ -201,13 +220,6 @@ void rx_func(void *param) { } up_removed++; } - for (j = 0; j < NUMBER_OF_NR_DLSCH_MAX; j++) - if (gNB->dlsch[j][0]->rnti == rnti_to_remove[i]) { - gNB->dlsch[j][0]->rnti = 0; - gNB->dlsch[j][0]->harq_mask = 0; - //clean_gNB_dlsch(gNB->dlsch[j][0]); - down_removed++; - } for (j = 0; j < NUMBER_OF_NR_PUCCH_MAX; j++) if (gNB->pucch[j]->active > 0 && gNB->pucch[j]->pucch_pdu.rnti == rnti_to_remove[i]) { @@ -224,7 +236,7 @@ void rx_func(void *param) { gNB->prach_vars.list[j].frame = -1; #endif } - if (rnti_to_remove_count) LOG_W(PHY, "to remove rnti_to_remove_count=%d, up_removed=%d down_removed=%d pucch_removed=%d\n", rnti_to_remove_count, up_removed, down_removed, pucch_removed); + if (rnti_to_remove_count) LOG_W(NR_PHY, "to remove rnti_to_remove_count=%d, up_removed=%d down_removed=%d pucch_removed=%d\n", rnti_to_remove_count, up_removed, down_removed, pucch_removed); rnti_to_remove_count = 0; if (pthread_mutex_unlock(&rnti_to_remove_mutex)) exit(1); @@ -255,7 +267,6 @@ void rx_func(void *param) { LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, frame_rx, slot_rx, frame_tx, slot_tx); // Call the scheduler - start_meas(&gNB->ul_indication_stats); pthread_mutex_lock(&gNB->UL_INFO_mutex); gNB->UL_INFO.frame = frame_rx; @@ -266,16 +277,17 @@ void rx_func(void *param) { pthread_mutex_unlock(&gNB->UL_INFO_mutex); stop_meas(&gNB->ul_indication_stats); - notifiedFIFO_elt_t *res; - if (tx_slot_type == NR_DOWNLINK_SLOT || tx_slot_type == NR_MIXED_SLOT) { + notifiedFIFO_elt_t *res; res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1_t *syncMsg = (processingData_L1_t *)NotifiedFifoData(res); + processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); + while (syncMsg->slot != slot_tx) { + pushNotifiedFIFO(gNB->resp_L1_tx, res); + res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); + syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); + } syncMsg->gNB = gNB; - syncMsg->frame_rx = frame_rx; - syncMsg->slot_rx = slot_rx; - syncMsg->frame_tx = frame_tx; - syncMsg->slot_tx = slot_tx; + AssertFatal(syncMsg->slot == slot_tx, "Thread message slot and logical slot number do not match\n"); syncMsg->timestamp_tx = info->timestamp_tx; res->key = slot_tx; pushTpool(gNB->threadPool, res); @@ -325,7 +337,6 @@ static void *process_stats_thread(void *param) { PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; - reset_meas(&gNB->phy_proc_tx); reset_meas(&gNB->dlsch_encoding_stats); reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->ul_indication_stats); @@ -337,7 +348,8 @@ static void *process_stats_thread(void *param) { while(!oai_exit) { sleep(1); - print_meas(&gNB->phy_proc_tx, "L1 Tx processing", NULL, NULL); + print_meas(gNB->phy_proc_tx_0, "L1 Tx processing thread 0", NULL, NULL); + print_meas(gNB->phy_proc_tx_1, "L1 Tx processing thread 1", NULL, NULL); print_meas(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL); print_meas(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL); print_meas(&gNB->ul_indication_stats, "UL Indication", NULL, NULL); @@ -356,6 +368,7 @@ void *nrL1_stats_thread(void *param) { fd=fopen("nrL1_stats.log","w"); AssertFatal(fd!=NULL,"Cannot open nrL1_stats.log\n"); dump_nr_I0_stats(fd,gNB); + dump_pdsch_stats(fd,gNB); dump_pusch_stats(fd,gNB); // nr_dump_uci_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); fclose(fd); @@ -390,14 +403,38 @@ void init_gNB_Tpool(int inst) { // L1 RX result FIFO gNB->resp_L1 = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); initNotifiedFIFO(gNB->resp_L1); + notifiedFIFO_elt_t *msg = newNotifiedFIFO_elt(sizeof(processingData_L1_t),0,gNB->resp_L1,rx_func); + pushNotifiedFIFO(gNB->resp_L1,msg); // to unblock the process in the beginning // L1 TX result FIFO gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); initNotifiedFIFO(gNB->resp_L1_tx); + // we create 2 threads for L1 tx processing + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); + processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + init_DLSCH_struct(gNB, msgDataTx); + msgDataTx->slot = -1; + memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + reset_meas(&msgDataTx->phy_proc_tx); + gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; + pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning + + msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); + msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + init_DLSCH_struct(gNB, msgDataTx); + msgDataTx->slot = -1; + memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + reset_meas(&msgDataTx->phy_proc_tx); + gNB->phy_proc_tx_1 = &msgDataTx->phy_proc_tx; + pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning // RU TX result FIFO gNB->resp_RU_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); initNotifiedFIFO(gNB->resp_RU_tx); + notifiedFIFO_elt_t *msgRUTx = newNotifiedFIFO_elt(sizeof(processingData_RU_t),0,gNB->resp_RU_tx,ru_tx_func); + processingData_RU_t *msgData = (processingData_RU_t*)msgRUTx->msgData; + msgData->next_slot = sf_ahead*gNB->frame_parms.slots_per_subframe; // first Tx slot + pushNotifiedFIFO(gNB->resp_RU_tx,msgRUTx); // to unblock the process in the beginning // Stats measurement thread if(opp_enabled == 1) threadCreate(&proc->process_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW); diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 2de04f4e7f..336b7bec12 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -33,6 +33,7 @@ #include "common/utils/assertions.h" #include "common/utils/system.h" +#include "common/ran_context.h" #include "../../ARCH/COMMON/common_lib.h" #include "../../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" @@ -47,8 +48,6 @@ #include "PHY/INIT/phy_init.h" #include "SCHED_NR/sched_nr.h" -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" - #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -301,15 +300,20 @@ void fh_if4p5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp) { /* Input Fronthaul from south RCC/RAU */ // Synchronous if5 from south + +uint64_t ts_rx[20]; void fh_if5_south_in(RU_t *ru, int *frame, int *tti) { NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; RU_proc_t *proc = &ru->proc; recv_IF5(ru, &proc->timestamp_rx, *tti, IF5_RRH_GW_UL); - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; - proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame); + if (proc->first_rx == 1) ru->ts_offset = proc->timestamp_rx; + proc->frame_rx = ((proc->timestamp_rx-ru->ts_offset) / (fp->samples_per_subframe*10))&1023; + proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx-ru->ts_offset,fp); +//(idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame); + ts_rx[*tti] = proc->timestamp_rx; + LOG_D(PHY,"IF5 %d.%d => RX %d.%d first_rx %d\n",*frame,*tti,proc->frame_rx,proc->tti_rx,proc->first_rx); if (proc->first_rx == 0) { if (proc->tti_rx != *tti) { @@ -318,7 +322,7 @@ void fh_if5_south_in(RU_t *ru, } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); + LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d proc->tti_rx %d tti %d)\n",proc->frame_rx,*frame,proc->tti_rx,*tti); exit_fun("Exiting"); } } else { @@ -610,6 +614,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { openair0_timestamp ts,old_ts; AssertFatal(*slotslots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame); + start_meas(&ru->rx_fhaul); for (i=0; inb_rx; i++) rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(*slot,fp,0)]; @@ -653,11 +658,11 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp); // synchronize first reception to frame 0 subframe 0 - LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n", + LOG_D(PHY,"RU %d/%d TS %llu , frame %d, slot %d.%d / %d\n", ru->idx, 0, - (unsigned long long int)proc->timestamp_rx, - (int)ru->ts_offset,proc->frame_rx,proc->tti_rx,proc->tti_tx,fp->slots_per_frame); + (unsigned long long int)(proc->timestamp_rx+ru->ts_offset), + proc->frame_rx,proc->tti_rx,proc->tti_tx,fp->slots_per_frame); // dump VCD output for first RU in list if (ru == RC.ru[0]) { @@ -683,12 +688,14 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { } //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",ru->timestamp_rx,proc->frame_rx,frame,proc->tti_rx,subframe); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, (proc->timestamp_rx+ru->ts_offset)&0xffffffff ); if (rxs != samples_per_slot) { //exit_fun( "problem receiving samples" ); LOG_E(PHY, "problem receiving samples\n"); } + + stop_meas(&ru->rx_fhaul); } @@ -698,13 +705,13 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { nfapi_nr_config_request_scf_t *cfg = &ru->config; void *txp[ru->nb_tx]; unsigned int txs; - int i,txsymb; + int i,txsymb=fp->symbols_per_slot; T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->samples_per_subframe * 4)); int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame); int prevslot_type = nr_slot_select(cfg,frame,(slot+(fp->slots_per_frame-1))%fp->slots_per_frame); int nextslot_type = nr_slot_select(cfg,frame,(slot+1)%fp->slots_per_frame); - int sf_extension = 0; //sf_extension = ru->sf_extension; + int sf_extension = 0; int siglen=fp->get_samples_per_slot(slot,fp); int flags=1; @@ -730,9 +737,10 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { flags = 3; // end of burst } - if (slot_type == NR_DOWNLINK_SLOT && prevslot_type == NR_UPLINK_SLOT) + if (slot_type == NR_DOWNLINK_SLOT && prevslot_type == NR_UPLINK_SLOT) { flags = 2; // start of burst - + sf_extension = ru->sf_extension; + } if (slot_type == NR_DOWNLINK_SLOT && nextslot_type == NR_UPLINK_SLOT) flags = 3; // end of burst } @@ -758,27 +766,28 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { flags |= beam<<8; LOG_D(HW,"slot %d, beam %d\n",slot,ru->common.beam_id[0][slot*fp->symbols_per_slot]); } + if (proc->first_tx == 1) proc->first_tx = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, flags ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot ); for (i=0; inb_tx; i++) - txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot,fp,0)-sf_extension]; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); + txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot,fp,0)]-sf_extension*sizeof(int32_t); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - // prepare tx buffer pointers + // prepare tx buffer pointers txs = ru->rfdevice.trx_write_func(&ru->rfdevice, timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, txp, siglen+sf_extension, ru->nb_tx, flags); - LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, slot %di, returned %d\n",ru->idx, - (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot, txs); + LOG_D(PHY,"[TXPATH] RU %d aa %d tx_rf, writing to TS %llu, %d.%d, unwrapped_frame %d, slot %d, flags %d, siglen+sf_extension %d, returned %d, E %f\n",ru->idx,i, + (long long unsigned int)(timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension),frame,slot,proc->frame_tx_unwrap,slot, flags, siglen+sf_extension, txs,10*log10((double)signal_energy(txp[0],siglen+sf_extension))); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - //AssertFatal(txs == 0,"trx write function error %d\n", txs); + //AssertFatal(txs == 0,"trx write function error %d\n", txs); } } @@ -793,79 +802,86 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { if (mu == NR_MU_0) { switch(N_RB) { - case 270: - if (fp->threequarter_fs) { - cfg->sample_rate=92.16e6; - cfg->samples_per_frame = 921600; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } - - case 216: - if (fp->threequarter_fs) { - cfg->sample_rate=46.08e6; - cfg->samples_per_frame = 460800; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } - - break; - - case 106: - if (fp->threequarter_fs) { - cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } else { - cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - - break; - - case 52: - if (fp->threequarter_fs) { - cfg->sample_rate=11.52e6; - cfg->samples_per_frame = 115200; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } else { - cfg->sample_rate=15.36e6; - cfg->samples_per_frame = 153600; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - - case 25: - if (fp->threequarter_fs) { - cfg->sample_rate=5.76e6; - cfg->samples_per_frame = 57600; - cfg->tx_bw = 5e6; - cfg->rx_bw = 5e6; - } else { - cfg->sample_rate=7.68e6; - cfg->samples_per_frame = 76800; - cfg->tx_bw = 5e6; - cfg->rx_bw = 5e6; - } - - break; - - default: - AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); + case 270: + if (fp->threequarter_fs) { + cfg->sample_rate=92.16e6; + cfg->samples_per_frame = 921600; + cfg->tx_bw = 50e6; + cfg->rx_bw = 50e6; + } else { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 614400; + cfg->tx_bw = 50e6; + cfg->rx_bw = 50e6; + } + case 216: + if (fp->threequarter_fs) { + cfg->sample_rate=46.08e6; + cfg->samples_per_frame = 460800; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + } + else { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 614400; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + } + break; + case 160: //30 MHz + case 133: //25 MHz + if (fp->threequarter_fs) { + AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); + } + else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + } + case 106: + if (fp->threequarter_fs) { + cfg->sample_rate=23.04e6; + cfg->samples_per_frame = 230400; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + } + else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + } + break; + case 52: + if (fp->threequarter_fs) { + cfg->sample_rate=11.52e6; + cfg->samples_per_frame = 115200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + else { + cfg->sample_rate=15.36e6; + cfg->samples_per_frame = 153600; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + case 25: + if (fp->threequarter_fs) { + cfg->sample_rate=5.76e6; + cfg->samples_per_frame = 57600; + cfg->tx_bw = 5e6; + cfg->rx_bw = 5e6; + } + else { + cfg->sample_rate=7.68e6; + cfg->samples_per_frame = 76800; + cfg->tx_bw = 5e6; + cfg->rx_bw = 5e6; + } + break; + default: + AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); } } else if (mu == NR_MU_1) { switch(N_RB) { @@ -896,6 +912,19 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->rx_bw = 80e6; } break; + case 162 : + if (fp->threequarter_fs) { + AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); + } + else { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 614400; + cfg->tx_bw = 60e6; + cfg->rx_bw = 60e6; + } + + break; + case 133 : if (fp->threequarter_fs) { AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); @@ -1139,8 +1168,7 @@ void *ru_stats_thread(void *param) { print_meas(&ru->ofdm_total_stats,"feptx_total",NULL,NULL); } - if (ru->fh_north_asynch_in) print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); - + print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); if (ru->fh_north_out) { @@ -1216,7 +1244,9 @@ void *ru_thread( void *param ) { int slot = fp->slots_per_frame-1; int frame = 1023; char threadname[40]; - int aa; + int initial_wait=0; + int opp_enabled0 = opp_enabled; + nfapi_nr_config_request_scf_t *cfg = &ru->config; // set default return value ru_thread_status = 0; @@ -1236,22 +1266,25 @@ void *ru_thread( void *param ) { exit(-1); } } else { + nr_init_frame_parms(&ru->config, fp); + nr_dump_frame_parms(fp); + fill_rf_config(ru,ru->rf_config_file); + nr_phy_init_RU(ru); + // Start IF device if any if (ru->nr_start_if) { LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); AssertFatal(ru->nr_start_if(ru,NULL) == 0, "Could not start the IF device\n"); - if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); - else ret = attach_rru(ru); + if (ru->has_ctrl_prt > 0) { + if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); + else ret = attach_rru(ru); + + AssertFatal(ret==0,"Cannot connect to remote radio\n"); + } - AssertFatal(ret==0,"Cannot connect to remote radio\n"); } - - if (ru->if_south == LOCAL_RF) { // configure RF parameters only - nr_init_frame_parms(&ru->config, fp); - nr_dump_frame_parms(fp); - fill_rf_config(ru,ru->rf_config_file); - nr_phy_init_RU(ru); + else if (ru->if_south == LOCAL_RF) { // configure RF parameters only ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); AssertFatal(ret==0,"Cannot connect to local radio\n"); } @@ -1263,20 +1296,15 @@ void *ru_thread( void *param ) { } sf_ahead = (uint16_t) ceil((float)6/(0x01<numerology_index)); - LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); + LOG_I(PHY, "Signaling main thread that RU %d is ready, sf_ahead %d\n",ru->idx,sf_ahead); pthread_mutex_lock(&RC.ru_mutex); RC.ru_mask &= ~(1<idx); pthread_cond_signal(&RC.ru_cond); pthread_mutex_unlock(&RC.ru_mutex); wait_sync("ru_thread"); - notifiedFIFO_elt_t *msg = newNotifiedFIFO_elt(sizeof(processingData_L1_t),0,gNB->resp_L1,rx_func); - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1_t),0,gNB->resp_L1_tx,tx_func); - notifiedFIFO_elt_t *msgRUTx = newNotifiedFIFO_elt(sizeof(processingData_L1_t),0,gNB->resp_RU_tx,ru_tx_func); + processingData_L1_t *syncMsg; notifiedFIFO_elt_t *res; - pushNotifiedFIFO(gNB->resp_L1,msg); // to unblock the process in the beginning - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning - pushNotifiedFIFO(gNB->resp_RU_tx,msgRUTx); // to unblock the process in the beginning if(!emulate_rf) { // Start RF device if any @@ -1316,6 +1344,19 @@ void *ru_thread( void *param ) { if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&slot); else AssertFatal(1==0, "No fronthaul interface at south port"); + if (initial_wait == 1 && proc->frame_rx < 300 && ru->fh_south_in == rx_rf) { + if (proc->frame_rx>0 && ((proc->frame_rx % 100) == 0) && proc->tti_rx==0) { + LOG_I(PHY,"delay processing to let RX stream settle, frame %d (trials %d)\n",proc->frame_rx,ru->rx_fhaul.trials); + print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); + reset_meas(&ru->rx_fhaul); + } + continue; + } + if (proc->frame_rx>=300) { + initial_wait=0; + opp_enabled = opp_enabled0; + } + if (initial_wait == 0 && ru->rx_fhaul.trials > 1000) reset_meas(&ru->rx_fhaul); proc->timestamp_tx = proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe); proc->frame_tx = (proc->tti_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; proc->tti_tx = (proc->tti_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame; @@ -1336,12 +1377,13 @@ void *ru_thread( void *param ) { ru->feprx(ru,proc->tti_rx); //LOG_M("rxdata.m","rxs",ru->common.rxdata[0],1228800,1,1); LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); +/* LOG_D(PHY,"Copying rxdataF from RU to gNB\n"); - for (aa=0; aanb_rx; aa++) + for (int aa=0; aanb_rx; aa++) memcpy((void *)RC.gNB[0]->common_vars.rxdataF[aa], (void *)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t)); - +*/ if (IS_SOFTMODEM_DOSCOPE && RC.gNB[0]->scopeData) ((scopeData_t *)RC.gNB[0]->scopeData)->slotFunc(ru->common.rxdataF[0],proc->tti_rx, RC.gNB[0]->scopeData); @@ -1405,13 +1447,24 @@ void *ru_thread( void *param ) { else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); } - delNotifiedFIFO_elt(msg); - delNotifiedFIFO_elt(msgL1Tx); - delNotifiedFIFO_elt(msgRUTx); + res = pullNotifiedFIFO(gNB->resp_L1); + delNotifiedFIFO_elt(res); + res = pullNotifiedFIFO(gNB->resp_L1_tx); + delNotifiedFIFO_elt(res); + res = pullNotifiedFIFO(gNB->resp_L1_tx); + delNotifiedFIFO_elt(res); + res = pullNotifiedFIFO(gNB->resp_RU_tx); + delNotifiedFIFO_elt(res); + ru_thread_status = 0; return &ru_thread_status; } +int start_streaming(RU_t *ru) { + LOG_I(PHY,"Starting streaming on third-party RRU\n"); + return(ru->ifdevice.thirdparty_startstreaming(&ru->ifdevice)); +} + int nr_start_if(struct RU_t_s *ru, struct PHY_VARS_gNB_s *gNB) { return(ru->ifdevice.trx_start_func(&ru->ifdevice)); } @@ -1668,6 +1721,7 @@ void set_function_spec_param(RU_t *ru) { switch (ru->if_south) { case LOCAL_RF: // this is an RU with integrated RF (RRU, gNB) + reset_meas(&ru->rx_fhaul); if (ru->function == NGFI_RRU_IF5) { // IF5 RRU ru->do_prach = 0; // no prach processing in RU ru->fh_north_in = NULL; // no shynchronous incoming fronthaul from north @@ -1705,7 +1759,6 @@ void set_function_spec_param(RU_t *ru) { ru->ifdevice.host_type = RRU_HOST; ru->rfdevice.host_type = RRU_HOST; ru->ifdevice.eth_params = &ru->eth_params; - reset_meas(&ru->rx_fhaul); reset_meas(&ru->tx_fhaul); reset_meas(&ru->compression); reset_meas(&ru->transport); @@ -1757,7 +1810,7 @@ void set_function_spec_param(RU_t *ru) { ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission ru->fh_south_asynch_in = NULL; // no asynchronous UL - ru->start_rf = NULL; // no local RF + ru->start_rf = ru->eth_params.transp_preference == ETH_UDP_IF5_ECPRI_MODE ? start_streaming : NULL; ru->stop_rf = NULL; ru->start_write_thread = NULL; ru->nr_start_if = nr_start_if; // need to start if interface for IF5 @@ -2013,7 +2066,7 @@ static void NRRCconfig_RU(void) { RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; - + RC.ru[j]->sf_extension = *(RUParamList.paramarray[j][RU_SF_EXTENSION_IDX].uptr); for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; } //strcmp(local_rf, "yes") == 0 else { @@ -2030,6 +2083,12 @@ static void NRRCconfig_RU(void) { RC.ru[j]->if_south = REMOTE_IF5; RC.ru[j]->function = NGFI_RAU_IF5; RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_ecpri_if5") == 0) { + RC.ru[j]->if_south = REMOTE_IF5; + RC.ru[j]->function = NGFI_RAU_IF5; + RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF5_ECPRI_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_ecpri_if5") == 0) { + RC.ru[j]->if_south = REMOTE_IF5; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { RC.ru[j]->if_south = REMOTE_IF5; RC.ru[j]->function = NGFI_RAU_IF5; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index c38c5217ae..3a6a795bb0 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -321,8 +321,8 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ UE->rf_map.card = card_offset; UE->rf_map.chain = CC_id + chain_offset; - LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, do_prb_interpolation %d\n", - UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->prb_interpolation); + LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, do_prb_interpolation %d\n", + UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->prb_interpolation); // Set FP variables @@ -331,7 +331,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ LOG_I(PHY, "Set UE frame_type %d\n", fp->frame_type); } - LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->threequarter_fs); + LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d, ssb_start_subcarrier %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->threequarter_fs, fp->ssb_start_subcarrier); fp->ofdm_offset_divisor = nrUE_params.ofdm_offset_divisor; @@ -438,7 +438,7 @@ int main( int argc, char **argv ) { itti_init(TASK_MAX, tasks_info); init_opt() ; - load_nrLDPClib(); + load_nrLDPClib(NULL); if (ouput_vcd) { vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd"); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 8469ffe790..7f47ed5eb3 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -50,7 +50,7 @@ { NOL2CONNECT_OPT, CONFIG_HLP_NOL2CN, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \ { CALIBPRACH_OPT, CONFIG_HLP_CALPRACH, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \ { DUMPFRAME_OPT, CONFIG_HLP_DUMPFRAME, PARAMFLAG_BOOL, iptr:&dumpframe, defintval:0, TYPE_INT, 0}, \ - {"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:0, TYPE_DOUBLE,0}, \ + {"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:110, TYPE_DOUBLE,0}, \ {"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE,0}, \ {"ue-txgain", CONFIG_HLP_UETXG, 0, dblptr:&(tx_gain[0][0]), defdblval:0, TYPE_DOUBLE,0}, \ {"ue-nb-ant-rx", CONFIG_HLP_UENANTR, 0, u8ptr:&(fp->nb_antennas_rx), defuintval:1, TYPE_UINT8, 0}, \ diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index c6a1eb44e4..3a7022a502 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -155,10 +155,10 @@ extern int usrp_tx_thread; {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, uptr:&nonbiot, defuintval:0, TYPE_INT, 0}, \ {"use-256qam-table", CONFIG_HLP_256QAM, PARAMFLAG_BOOL, iptr:&USE_256QAM_TABLE, defintval:0, TYPE_INT, 0}, \ - {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&PRB_INTERPOLATION, defintval:0, TYPE_INT, 0}, \ - {"usrp-tx-thread-config",CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ - {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ - {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ + {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&PRB_INTERPOLATION, defintval:0, TYPE_INT, 0}, \ + {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ + {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ + {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ } diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 2b1900200a..4edbeee342 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1104,25 +1104,70 @@ void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) { free(header); } +notifiedFIFO_elt_t *l1tx_message_extract(PHY_VARS_gNB *gNB, int frame, int slot) { + notifiedFIFO_elt_t *res; + notifiedFIFO_elt_t *freeRes = NULL; + + // check first message + res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + if (msgTx->slot == slot) { + return res; + } + if (msgTx->slot == -1) { + freeRes = res; + } + + // check second message + pushNotifiedFIFO(gNB->resp_L1_tx,res); + res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); + msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + if (msgTx->slot == slot) { + return res; + } + if (msgTx->slot == -1) { + freeRes = res; + } + + if (freeRes) { + msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + msgTx->num_pdsch_slot=0; + msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->slot = slot; + msgTx->frame = frame; + return freeRes; + } + pushNotifiedFIFO(gNB->resp_L1_tx,res); + AssertFatal(1==0, "It means both L1 Tx messages are still waiting to be processed. This happens when L1 Tx processing is too slow. Message slot %d, scheduled slot %d\n", + msgTx->slot, slot); +} int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) { // LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; + + // extract the next available thread message (priority to message with current slot, then free message) + notifiedFIFO_elt_t *res; + res = l1tx_message_extract(gNB, req->SFN, req->Slot); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + if (proc ==NULL) proc = &gNB->proc.L1_proc; - for (int i=0; inumPdus; i++) { - if (req->ul_dci_pdu_list[i].PDUType == 0) { - nfapi_nr_ul_dci_request_pdus_t *ul_dci_req_pdu = &req->ul_dci_pdu_list[i]; - handle_nfapi_nr_ul_dci_pdu(gNB, req->SFN, req->Slot, ul_dci_req_pdu); + if (req->numPdus > 0) { + if (req->ul_dci_pdu_list[req->numPdus-1].PDUType == 0) { // copy only the last PDU (PHY can have only one UL PDCCH pdu) + msgTx->ul_pdcch_pdu = req->ul_dci_pdu_list[req->numPdus-1]; // copy the last pdu } else { - LOG_E(PHY,"[PNF] UL_DCI_REQ sfn_slot:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSLOT2DEC(req->SFN, req->Slot), i, req->ul_dci_pdu_list[i].PDUType); + LOG_E(PHY,"[PNF] UL_DCI_REQ sfn_slot:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSLOT2DEC(req->SFN, req->Slot), req->numPdus-1, req->ul_dci_pdu_list[req->numPdus-1].PDUType); } } + pushNotifiedFIFO(gNB->resp_L1_tx,res); + return 0; } @@ -1193,14 +1238,17 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, for (int i=0; idl_tti_request_body.nPDUs; i++) { // NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d pdcch_vars->num_dci:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size,pdcch_vars->num_dci); + notifiedFIFO_elt_t *res; + res = l1tx_message_extract(gNB, sfn, slot); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) { - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu=&dl_tti_pdu_list[i]; - handle_nfapi_nr_pdcch_pdu(gNB, sfn, slot, &dl_tti_pdu->pdcch_pdu); + // we trust the scheduler sends only one PDCCH PDU per slot + msgTx->pdcch_pdu = dl_tti_pdu_list[i].pdcch_pdu; // fills the last received PDCCH PDU } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PDU:%d BCH: pdu_index:%u pdu_length:%d sdu_length:%d BCH_SDU:%x,%x,%x\n", __FUNCTION__, i, pdu_index, bch_pdu->bch_pdu_rel8.length, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length, sdu[0], sdu[1], sdu[2]); - handle_nr_nfapi_ssb_pdu(gNB, sfn, slot, &dl_tti_pdu_list[i]); + handle_nr_nfapi_ssb_pdu(msgTx, sfn, slot, &dl_tti_pdu_list[i]); gNB->pbch_configured=1; } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) { @@ -1209,21 +1257,11 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_pdu_t *tx_data = tx_data_request[sfn][slot][rel15_pdu->pduIndex]; if (tx_data != NULL) { - int UE_id = find_nr_dlsch(rel15_pdu->rnti,gNB,SEARCH_EXIST_OR_FREE); - AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); - NR_gNB_DLSCH_t *dlsch0 = gNB->dlsch[UE_id][0]; - int harq_pid = dlsch0->harq_ids[sfn%2][slot]; - - if(harq_pid >= dlsch0->Mdlharq) { - LOG_E(PHY,"pnf_phy_dl_config_req illegal harq_pid %d\n", harq_pid); - return(-1); - } - - uint8_t *dlsch_sdu = nr_tx_pdus[UE_id][harq_pid]; - memcpy(dlsch_sdu, tx_data->TLVs[0].value.direct,tx_data->PDU_length); + uint8_t *dlsch_sdu = (uint8_t *)tx_data->TLVs[0].value.direct; //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() DLSCH:pdu_index:%d handle_nfapi_dlsch_pdu(eNB, proc_rxtx, dlsch_pdu, transport_blocks:%d sdu:%p) eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols:%d\n", __FUNCTION__, rel8_pdu->pdu_index, rel8_pdu->transport_blocks, dlsch_sdu, eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols); - handle_nr_nfapi_pdsch_pdu(gNB, sfn, slot,pdsch_pdu, dlsch_sdu); + AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", + msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); + handle_nr_nfapi_pdsch_pdu(msgTx, pdsch_pdu, dlsch_sdu); } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() DLSCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSLOT2DEC(sfn,slot), rel15_pdu->pduIndex); @@ -1231,11 +1269,12 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE) { nfapi_nr_dl_tti_csi_rs_pdu *csi_rs_pdu = &dl_tti_pdu_list[i].csi_rs_pdu; - handle_nfapi_nr_csirs_pdu(gNB, sfn, slot, csi_rs_pdu); + handle_nfapi_nr_csirs_pdu(msgTx, sfn, slot, csi_rs_pdu); } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_tti_pdu_list[i].PDUType); } + pushNotifiedFIFO(gNB->resp_L1_tx,res); } if(req->vendor_extension) diff --git a/openair1/PHY/CODING/DOC/LDPCImplementation.md b/openair1/PHY/CODING/DOC/LDPCImplementation.md index 89ae6b4dbb..c5411540b6 100644 --- a/openair1/PHY/CODING/DOC/LDPCImplementation.md +++ b/openair1/PHY/CODING/DOC/LDPCImplementation.md @@ -1,11 +1,13 @@ -#LDPC coder/decoder implementation +# LDPC coder/decoder implementation The LDPC coder and decoder are implemented in a shared library, dynamically loaded at run-time using the [oai shared library loader](file://../../../../common/utils/DOC/loader.md). The code loading the LDPC library is in [nrLDPC_load.c](file://../nrLDPC_load.c), in function `load_nrLDPClib`, which must be called at init time. ## Selecting the LDPC library at run time By default the function `int load_nrLDPClib(void)` looks for `libldpc.so`, this default behavior can be changed using the oai loader configuration options in the configuration file or from the command line as shown below: ->loading `libldpc_optim8seg.so` instead of `libldpc.so` +#### Examples of ldpc shared lib selection when running nr softmodem's: + +loading `libldpc_optim8seg.so` instead of `libldpc.so`: ``` ./nr-softmodem -O libconfig:gnb.band78.tm1.106PRB.usrpx300.conf:dbgl5 --loader.ldpc.shlibversion _optim8seg @@ -18,9 +20,160 @@ By default the function `int load_nrLDPClib(void)` looks for `libldpc.so`, this ........................ ``` -Today, this mechanism is not available in the `ldpctest` phy simulator which doesn't initialize the [configuration module](file://../../../../common/config/DOC/config.md). loads `libldpc.so` and `libldpc_orig.so` to compare the performance of the two implementations. +loading `libldpc_cl.so` instead of `libldpc.so`: -###LDPC libraries -Libraries implementing the LDPC algorithms must be named `libldpc<_version>.so`, they must implement two functions: `nrLDPC_decod` and `nrLDPC_encod`. The prototypes for these functions is defined in [nrLDPC_defs.h](file://nrLDPC_defs.h). +`make ldpc_cl` + +`cp ../../../openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl` + +`./nr-softmodem -O libconfig:gnb.band78.sa.fr1.106PRB.usrpb210.conf:dbgl5 --rfsim --rfsimulator.serveraddr server --sa --log_config.gtpu_log_level info --loader.ldpc.shlibversion _cl` + +``` [LOADER] library libldpc_cl.so successfully loaded +------------------------------------------------ +[HW] Platform 0, OpenCL profile FULL_PROFILE +[HW] Platform 0, OpenCL version OpenCL 2.1 LINUX +[HW] Device 0 is available +[HW] Device 0, type 2 = 0x00000002: cpu +[HW] Device 0, number of Compute Units: 8 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 8192 +[HW] Device 0, max Work Items size for dimension: 1 8192 +[HW] Device 0, max Work Items size for dimension: 2 8192 +[New Thread 0x7fffcc258700 (LWP 3945123)] +[New Thread 0x7fffc3e57700 (LWP 3945124)] +[New Thread 0x7fffcbe57700 (LWP 3945125)] +[New Thread 0x7fffcba56700 (LWP 3945126)] +[New Thread 0x7fffcb254700 (LWP 3945128)] +[New Thread 0x7fffcb655700 (LWP 3945127)] +[New Thread 0x7fffcae53700 (LWP 3945129)] +[HW] Platform 1, OpenCL profile FULL_PROFILE +[HW] Platform 1, OpenCL version OpenCL 2.0 beignet 1.3 +[New Thread 0x7fffc965a700 (LWP 3945130)] +[Thread 0x7fffc965a700 (LWP 3945130) exited] +[HW] Device 0 is available +[HW] Device 0, type 4 = 0x00000004: gpu +[HW] Device 0, number of Compute Units: 20 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 512 +[HW] Device 0, max Work Items size for dimension: 1 512 +[HW] Device 0, max Work Items size for dimension: 2 512 +----------------------------------------------------------------- +``` + +`./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa -O libconfig:/usr/local/oai/conf/nrue_sim.conf:dbgl5 --nokrnmod --loader.ldpc.shlibversion _cl --log_config.hw_log_level info` + +```[CONFIG] shlibversion set to _cl from command line +............................................................ +[CONFIG] loader.ldpc 1 options set from command line +[LOADER] library libldpc_cl.so successfully loaded +[HW] Platform 0, OpenCL profile FULL_PROFILE +[HW] Platform 0, OpenCL version OpenCL 2.1 LINUX +[HW] Device 0 is available +[HW] Device 0, type 2 = 0x00000002: cpu +[HW] Device 0, number of Compute Units: 8 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 8192 +[HW] Device 0, max Work Items size for dimension: 1 8192 +[HW] Device 0, max Work Items size for dimension: 2 8192 +[New Thread 0x7fffecccc700 (LWP 3945413)] +[New Thread 0x7fffec8cb700 (LWP 3945415)] +[New Thread 0x7fffec4ca700 (LWP 3945414)] +[New Thread 0x7fffdf7fd700 (LWP 3945417)] +[New Thread 0x7fffdfbfe700 (LWP 3945418)] +[New Thread 0x7fffdffff700 (LWP 3945416)] +[New Thread 0x7fffd73fc700 (LWP 3945419)] +[HW] Platform 1, OpenCL profile FULL_PROFILE +[HW] Platform 1, OpenCL version OpenCL 2.0 beignet 1.3 +[New Thread 0x7fffde105700 (LWP 3945420)] +[Thread 0x7fffde105700 (LWP 3945420) exited] +[HW] Device 0 is available +[HW] Device 0, type 4 = 0x00000004: gpu +[HW] Device 0, number of Compute Units: 20 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 512 +[HW] Device 0, max Work Items size for dimension: 1 512 +[HW] Device 0, max Work Items size for dimension: 2 512 +------------------------------------------------------------ +​``` +``` + +A mechanism to select ldpc implementation is also available in the `ldpctest` phy simulator via the `-v`option, which can be used to specify the version of the ldpc shared library to be used. + +#### Examples of ldpc shared lib selection when running ldpctest: + +Loading libldpc_cuda.so, the cuda implementation of the ldpc decoder: + +```$ ./ldpctest -v _cuda +Initializing random number generator, seed 0 +block length 8448: +n_trials 1: +SNR0 -2.000000: +[CONFIG] get parameters from cmdline , debug flags: 0x00400000 +[CONFIG] log_config: 2/3 parameters successfully set +[CONFIG] log_config: 53/53 parameters successfully set +[CONFIG] log_config: 53/53 parameters successfully set +[CONFIG] log_config: 16/16 parameters successfully set +[CONFIG] log_config: 16/16 parameters successfully set +log init done +[CONFIG] loader: 2/2 parameters successfully set +[CONFIG] loader.ldpc: 1/2 parameters successfully set +[LOADER] library libldpc_cuda.so successfully loaded +................................... +​``` +``` + +Loading libldpc_cl.so, the opencl implementation of the ldpc decoder: + +`make ldpc_cl` + +`cp ../../../openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl` + +`./ldpctest -v _cl` + +```$ ./ldpctest -v _cl +Initializing random number generator, seed 0 +block length 8448: +n_trials 1: +SNR0 -2.000000: +[CONFIG] get parameters from cmdline , debug flags: 0x00400000 +[CONFIG] log_config: 2/3 parameters successfully set +[CONFIG] log_config: 53/53 parameters successfully set +[CONFIG] log_config: 53/53 parameters successfully set +[CONFIG] log_config: 16/16 parameters successfully set +[CONFIG] log_config: 16/16 parameters successfully set +log init done +[CONFIG] loader: 2/2 parameters successfully set +[CONFIG] loader.ldpc: 1/2 parameters successfully set +[LOADER] library libldpc_cl.so successfully loaded +[HW] Platform 0, OpenCL profile FULL_PROFILE +[HW] Platform 0, OpenCL version OpenCL 2.1 LINUX +[HW] Device 0 is available +[HW] Device 0, type 2 = 0x00000002: cpu +[HW] Device 0, number of Compute Units: 8 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 8192 +[HW] Device 0, max Work Items size for dimension: 1 8192 +[HW] Device 0, max Work Items size for dimension: 2 8192 +[HW] Platform 1, OpenCL profile FULL_PROFILE +[HW] Platform 1, OpenCL version OpenCL 2.0 beignet 1.3 +[HW] Device 0 is available +[HW] Device 0, type 4 = 0x00000004: gpu +[HW] Device 0, number of Compute Units: 20 +[HW] Device 0, max Work Items dimension: 3 +[HW] Device 0, max Work Items size for dimension: 0 512 +[HW] Device 0, max Work Items size for dimension: 1 512 +[HW] Device 0, max Work Items size for dimension: 2 512 +................................ +​``` +``` + + + +### LDPC libraries +Libraries implementing the LDPC algorithms must be named `libldpc<_version>.so`, they must implement three functions: `nrLDPC_initcall` `nrLDPC_decod` and `nrLDPC_encod`. The prototypes for these functions is defined in [nrLDPC_defs.h](file://nrLDPC_defs.h). + +`libldpc_cuda.so`has been tested with the `ldpctest` executable, usage from the softmodem's has to be tested. + +`libldpc_cl`is under development. [oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 91c5d59611..aff707a1d5 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -101,8 +101,8 @@ int test_ldpc(short No_iteration, unsigned int *crc_misses, time_stats_t *time_optim, time_stats_t *time_decoder, - n_iter_stats_t *dec_iter, - short run_cuda) + n_iter_stats_t *dec_iter + ) { //clock initiate //time_stats_t time,time_optim,tinput,tprep,tparity,toutput, time_decoder; @@ -393,28 +393,13 @@ int test_ldpc(short No_iteration, decParams.R=code_rate_vec[R_ind];//13; decParams.numMaxIter=No_iteration; decParams.outMode = nrLDPC_outMode_BIT; + decParams.block_length=block_length; //decParams.outMode =nrLDPC_outMode_LLRINT8; -#ifdef CUDA_FLAG - set_compact_BG(Zc,BG); - init_LLR_DMA_for_CUDA(&decParams, (int8_t*)channel_output_fixed[j], (int8_t*)estimated_output[j], block_length); -#endif + nrLDPC_initcall(&decParams, (int8_t*)channel_output_fixed[j], (int8_t*)estimated_output[j]); for(j=0;j 1280, 2401 -> 2560 - + char *ldpc_version=NULL; /* version of the ldpc decoder library to use (XXX suffix to use when loading libldpc_XXX.so */ short No_iteration=5; int n_segments=1; //double rate=0.333; - short run_cuda = 0; int nom_rate=1; int denom_rate=3; @@ -544,7 +526,7 @@ int main(int argc, char *argv[]) short BG=0,Zc,Kb=0; - while ((c = getopt (argc, argv, "q:r:s:S:l:G:n:d:i:t:u:h")) != -1) + while ((c = getopt (argc, argv, "q:r:s:S:l:G:n:d:i:t:u:hv:")) != -1) switch (c) { case 'q': @@ -564,7 +546,7 @@ int main(int argc, char *argv[]) break; case 'G': - run_cuda = atoi(optarg); + ldpc_version="_cuda"; break; case 'n': @@ -590,9 +572,11 @@ int main(int argc, char *argv[]) case 'u': test_uncoded = atoi(optarg); break; - + case 'v': + ldpc_version=strdup(optarg); + break; case 'h': - default: + default: printf("CURRENTLY SUPPORTED CODE RATES: \n"); printf("BG1 (blocklength > 3840): 1/3, 2/3, 22/25 (8/9) \n"); printf("BG2 (blocklength <= 3840): 1/5, 1/3, 2/3 \n\n"); @@ -609,6 +593,7 @@ int main(int argc, char *argv[]) printf("-t SNR simulation step, Default: 0.1\n"); printf("-i Max decoder iterations, Default: 5\n"); printf("-u Set SNR per coded bit, Default: 0\n"); + printf("-v XXX Set ldpc shared library version. libldpc_XXX.so will be used \n"); exit(1); break; } @@ -619,7 +604,10 @@ int main(int argc, char *argv[]) printf("SNR0 %f: \n", SNR0); - load_nrLDPClib(); + if (ldpc_version != NULL) + load_nrLDPClib(ldpc_version); + else + load_nrLDPClib(NULL); load_nrLDPClib_ref("_orig", &encoder_orig); //for (block_length=8;block_length<=MAX_BLOCK_LENGTH;block_length+=8) @@ -691,8 +679,7 @@ int main(int argc, char *argv[]) &crc_misses, time_optim, time_decoder, - dec_iter, - run_cuda); + dec_iter); printf("SNR %f, BLER %f (%u/%d)\n", SNR, (float)decoded_errors[i]/(float)n_trials, decoded_errors[i], n_trials); printf("SNR %f, BER %f (%u/%d)\n", SNR, (float)errors_bit/(float)n_trials/(float)block_length/(double)n_segments, decoded_errors[i], n_trials); diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c index 3226c97f87..166cd9a5a3 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c @@ -46,7 +46,8 @@ #endif static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); - +void nrLDPC_initcall(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out) { +} int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler) { uint32_t numLLR; @@ -55,7 +56,6 @@ int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_ t_nrLDPC_lut* p_lut = &lut; //printf("p_procBuf->cnProcBuf = %p\n", p_procBuf->cnProcBuf); - // Initialize decoder core(s) with correct LUTs numLLR = nrLDPC_init(p_decParams, p_lut); @@ -231,7 +231,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP // First iteration finished - while ( (i < (numMaxIter-1)) && (pcRes != 0) ) + while ( (i < numMaxIter) && (pcRes != 0) ) { // Increase iteration counter i++; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c new file mode 100644 index 0000000000..58e6b507af --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c @@ -0,0 +1,436 @@ +/* + * 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.0 (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 + */ + /*! \file nrLDPC_decoder_CL.c +* \brief ldpc decoder, openCL implementaion +* \author Francois TABURET +* \date 2021 +* \version 1.0 +* \note initial implem - translation of cuda version +*/ +/* uses HW component id for log messages ( --log_config.hw_log_level ) */ +#include +#include +#include +#include +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPCdecoder_defs.h" +#include "assertions.h" +#include "common/utils/LOG/log.h" + +#define MAX_ITERATION 2 +#define MC 1 + +#define MAX_OCLDEV 10 +#define MAX_OCLRUNTIME 5 + + +#define CLSETKERNELARG(A,B,C,D) \ +rt=clSetKernelArg(A,B,C,D) ;\ +AssertFatal(rt == CL_SUCCESS, "Error %d setting kernel argument index %d\n" , (int)rt, B); + +typedef struct{ + char x; + char y; + short value; +} h_element; +#include "../nrLDPC_decoder_LYC/bgs/BG1_compact_in_C.h" + +typedef struct{ + cl_uint max_CU; + cl_uint max_WID; + size_t *max_WIS; +} ocldev_t; + +typedef struct { + cl_kernel cnp_kernel_1st; + cl_kernel cnp_kernel; + cl_kernel vnp_kernel_normal; + cl_kernel pack_decoded_bit; +} oclkernels_t; + +typedef struct{ + cl_uint num_devices; + cl_device_id devices[MAX_OCLDEV]; + ocldev_t ocldev[MAX_OCLDEV]; + cl_context context; + cl_program program; + cl_mem dev_h_compact1; + cl_mem dev_h_compact2; + cl_mem dev_const_llr; + cl_mem dev_llr; + cl_mem dev_dt; + cl_mem dev_tmp; + oclkernels_t kernels[MAX_OCLDEV]; + cl_command_queue queue[MAX_OCLDEV]; +} oclruntime_t; + +typedef struct{ + oclruntime_t runtime[MAX_OCLRUNTIME]; +} ocl_t; + + + +ocl_t ocl; + + +void set_compact_BG(int Zc,short BG){ + cl_uint rt; + int row,col; + if(BG == 1){ + row = 46; + col = 68; + } + else{ + row = 42; + col = 52; + } + int compact_row = 30; + int compact_col = 19; + if(BG==2){compact_row = 10, compact_col = 23;} + int memorySize_h_compact1 = row * compact_col * sizeof(h_element); + int memorySize_h_compact2 = compact_row * col * sizeof(h_element); + int lift_index = 0; + short lift_set[][9] = { + {2,4,8,16,32,64,128,256}, + {3,6,12,24,48,96,192,384}, + {5,10,20,40,80,160,320}, + {7,14,28,56,112,224}, + {9,18,36,72,144,288}, + {11,22,44,88,176,352}, + {13,26,52,104,208}, + {15,30,60,120,240}, + {0} + }; + + for(int i = 0; lift_set[i][0] != 0; i++){ + for(int j = 0; lift_set[i][j] != 0; j++){ + if(Zc == lift_set[i][j]){ + lift_index = i; + break; + } + } + } + printf("\nZc = %d BG = %d\n",Zc,BG); + ocl.runtime[0].dev_h_compact1 = clCreateBuffer(ocl.runtime[0].context, CL_MEM_READ_ONLY|CL_MEM_HOST_WRITE_ONLY, memorySize_h_compact1, NULL, (cl_int *)&rt); + AssertFatal(rt == CL_SUCCESS, "Error %d creating buffer dev_h_compact1 for platform %i \n" , (int)rt, 0); + ocl.runtime[0].dev_h_compact2 = clCreateBuffer(ocl.runtime[0].context, CL_MEM_READ_ONLY|CL_MEM_HOST_WRITE_ONLY, memorySize_h_compact2, NULL, (cl_int *)&rt); + AssertFatal(rt == CL_SUCCESS, "Error %d creating buffer dev_h_compact2 for platform %i \n" , (int)rt, 0); + h_element *h1; + h_element *h2; + switch(lift_index){ + case 0: + h1 = host_h_compact1_I0; + h2 = host_h_compact2_I0; + break; + case 1: + h1 = host_h_compact1_I1; + h2 = host_h_compact2_I1; + break; + case 2: + h1 = host_h_compact1_I2; + h2 = host_h_compact2_I2; + break; + case 3: + h1 = host_h_compact1_I3; + h2 = host_h_compact2_I3; + break; + case 4: + h1 = host_h_compact1_I4; + h2 = host_h_compact2_I4; + break; + case 5: + h1 = host_h_compact1_I5; + h2 = host_h_compact2_I5; + break; + case 6: + h1 = host_h_compact1_I6; + h2 = host_h_compact2_I6; + break; + case 7: + h1 = host_h_compact1_I7; + h2 = host_h_compact2_I7; + break; + default: + AssertFatal(0, "Invalid lift_index value %i\n" , lift_index); + break; + } + rt = clEnqueueWriteBuffer(ocl.runtime[0].queue[0], ocl.runtime[0].dev_h_compact1, CL_TRUE, 0,memorySize_h_compact1, h1, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d moving h_compact1 memory to pltf %i dev %i\n" , (int)rt, 0,0); + rt = clEnqueueWriteBuffer(ocl.runtime[0].queue[0], ocl.runtime[0].dev_h_compact2, CL_TRUE, 0,memorySize_h_compact2, h2, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d moving h_compact2 memory to pltf %i dev %i\n" , (int)rt, 0,0); + // return 0; +} +void cl_error_callback(const char* errinfo, const void* private_info, size_t cb, void* user_data) { + oclruntime_t *runtime = (oclruntime_t *)user_data; + LOG_E(HW,"OpenCL accelerator error %s\n", errinfo ); +} + +char *clutil_getstrdev(int intdev) { + static char retstring[255]=""; + char *retptr=retstring; + retptr+=sprintf(retptr,"0x%08x: ",(uint32_t)intdev); + if (intdev & CL_DEVICE_TYPE_CPU) + retptr+=sprintf(retptr,"%s","cpu "); + if (intdev & CL_DEVICE_TYPE_GPU) + retptr+=sprintf(retptr,"%s","gpu "); + if (intdev & CL_DEVICE_TYPE_ACCELERATOR) + retptr+=sprintf(retptr,"%s","acc "); + return retstring; +} + +void get_CompilErr(cl_program program, int pltf) { + + // Determine the size of the log + size_t log_size; + for(int i=0; i0 , "clGetPlatformIDs: no cl compatible platform found\n"); + for (int i=0 ; i<(int)num_platforms_found ; i++) { + char stringval[255]; + rt = clGetPlatformInfo(platforms[i],CL_PLATFORM_PROFILE, sizeof(stringval),stringval,NULL); + AssertFatal(rt == CL_SUCCESS, "clGetPlatformInfo PROFILE error %d\n" , (int)rt); + LOG_I(HW,"Platform %i, OpenCL profile %s\n", i,stringval ); + rt = clGetPlatformInfo(platforms[i],CL_PLATFORM_VERSION, sizeof(stringval),stringval,NULL); + AssertFatal(rt == CL_SUCCESS, "clGetPlatformInfo VERSION error %d\n" , (int)rt); + LOG_I(HW,"Platform %i, OpenCL version %s\n", i,stringval ); + rt = clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_ALL, sizeof(ocl.runtime[i].devices)/sizeof(cl_device_id),ocl.runtime[i].devices,&(ocl.runtime[i].num_devices)); + AssertFatal(rt == CL_SUCCESS, "clGetDeviceIDs error %d\n" , (int)rt); + int devok=0; + for (int j=0; j0) { + ocl.runtime[i].context = clCreateContext(NULL, ocl.runtime[i].num_devices, ocl.runtime[i].devices, cl_error_callback, &(ocl.runtime[i]), (cl_int *)&rt); + AssertFatal(rt == CL_SUCCESS, "Error %d creating context for platform %i\n" , (int)rt, i); + for(int dev=0; dev0, "No openCL device available to accelerate ldpc\n"); + return 0; +} + + +void nrLDPC_initcall(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out) { + set_compact_BG(p_decParams->Z,p_decParams->BG); +// init_LLR_DMA(p_decParams, p_llr, p_out); +} + + +int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out,t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats *time_decoder) +{ + uint16_t Zc = p_decParams->Z; + uint8_t BG = p_decParams->BG; +// uint8_t numMaxIter = p_decParams->numMaxIter; + int block_length = p_decParams->block_length; +// e_nrLDPC_outMode outMode = p_decParams->outMode; + uint8_t row,col; + if(BG == 1){ + row = 46; + col = 68; + } + else{ + row = 42; + col = 52; + } + +// alloc memory +// unsigned char *hard_decision = (unsigned char*)p_out; +// gpu + int memorySize_llr = col * Zc * sizeof(char) * MC; +// cudaCheck( cudaMemcpyToSymbol(dev_const_llr, p_llr, memorySize_llr_cuda) ); +// cudaCheck( cudaMemcpyToSymbol(dev_llr, p_llr, memorySize_llr_cuda) ); + int rt = clEnqueueWriteBuffer(ocl.runtime[0].queue[0], ocl.runtime[0].dev_const_llr, CL_TRUE, 0, + memorySize_llr, p_llr, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d moving p_llr data to read only memory in pltf %i dev %i\n" , (int)rt, 0,0); + rt = clEnqueueWriteBuffer(ocl.runtime[0].queue[0], ocl.runtime[0].dev_llr, CL_TRUE, 0, + memorySize_llr, p_llr, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d moving p_llr data to read-write memory in pltf %i dev %i\n" , (int)rt, 0,0); +// Define CUDA kernel dimension +// int blockSizeX = Zc; +// dim3 dimGridKernel1(row, MC, 1); // dim of the thread blocks +// dim3 dimBlockKernel1(blockSizeX, 1, 1); + +// dim3 dimGridKernel2(col, MC, 1); +// dim3 dimBlockKernel2(blockSizeX, 1, 1); +// cudaDeviceSynchronize(); + +// lauch kernel + size_t global_item_sizek0[2] = {row*Zc,MC}; // Process the entire lists + size_t global_item_sizek1[2] = {col*Zc,MC}; // Process the entire lists + size_t local_item_sizek[2] = {128,1}; // Divide work items into groups of 128 + + for(int ii = 0; ii < MAX_ITERATION; ii++){ + // first kernel + if(ii == 0){ +// ldpc_cnp_kernel_1st_iter +// <<>> +// ( BG, row, col, Zc); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 0, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_llr)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 1, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_dt)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 2, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_h_compact1)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 3, sizeof(int), (void *)&(BG)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 4, sizeof(int), (void *)&(row)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 5, sizeof(int), (void *)&(col)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel_1st, 6, sizeof(int), (void *)&(Zc)); + rt = clEnqueueNDRangeKernel(ocl.runtime[0].queue[0], ocl.runtime[0].kernels[0].cnp_kernel_1st, 2, NULL, + global_item_sizek0, local_item_sizek, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d enqueing cnp_kernel_1st \n" , (int)rt); + }else{ +// ldpc_cnp_kernel +// <<>> +// ( BG, row, col, Zc); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 0, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_llr)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 1, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_dt)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 2, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_h_compact1)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 3, sizeof(int), (void *)&(BG)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 4, sizeof(int), (void *)&(row)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 5, sizeof(int), (void *)&(col)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].cnp_kernel, 6, sizeof(int), (void *)&(Zc)); + rt = clEnqueueNDRangeKernel(ocl.runtime[0].queue[0], ocl.runtime[0].kernels[0].cnp_kernel, 2, NULL, + global_item_sizek0, local_item_sizek, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d enqueing cnp_kernel\n" , (int)rt); + } + // second kernel +// ldpc_vnp_kernel_normal +// <<>> +// // (dev_llr, dev_const_llr,BG, row, col, Zc); +// (BG, row, col, Zc); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 0, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_llr)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 1, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_dt)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 2, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_const_llr)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 3, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_h_compact2)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 4, sizeof(int), (void *)&(BG)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 5, sizeof(int), (void *)&(row)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 6, sizeof(int), (void *)&(col)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].vnp_kernel_normal, 7, sizeof(int), (void *)&(Zc)); + rt = clEnqueueNDRangeKernel(ocl.runtime[0].queue[0], ocl.runtime[0].kernels[0].vnp_kernel_normal, 2, NULL, + global_item_sizek1, local_item_sizek, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d enqueing vnp_kernel_normal \n" , (int)rt); + } + +// int pack = (block_length/128)+1; +// dim3 pack_block(pack, MC, 1); +// pack_decoded_bit<<>>( col, Zc); + CLSETKERNELARG(ocl.runtime[0].kernels[0].pack_decoded_bit, 0, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_llr)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].pack_decoded_bit, 1, sizeof(cl_mem), (void *)&(ocl.runtime[0].dev_tmp)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].pack_decoded_bit, 2, sizeof(int), (void *)&(col)); + CLSETKERNELARG(ocl.runtime[0].kernels[0].pack_decoded_bit, 3, sizeof(int), (void *)&(Zc)); + + // Execute the OpenCL kernel on the list + size_t global_item_size[2] = {block_length,MC}; // Process the entire lists + size_t local_item_size[2] = {128,1}; // Divide work items into groups of 128 + rt = clEnqueueNDRangeKernel(ocl.runtime[0].queue[0], ocl.runtime[0].kernels[0].pack_decoded_bit, 2, NULL, + global_item_size, local_item_size, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d enqueing pack_decoded_bit \n" , (int)rt); +// cudaCheck( cudaMemcpyFromSymbol((void*)hard_decision, (const void*)dev_tmp, (block_length/8)*sizeof(unsigned char)) ); +// cudaDeviceSynchronize(); + + rt = clEnqueueReadBuffer(ocl.runtime[0].queue[0], ocl.runtime[0].dev_tmp, CL_TRUE, 0, + (block_length/8)*sizeof(unsigned char) , p_llr, 0, NULL, NULL); + AssertFatal(rt == CL_SUCCESS, "Error %d moving p_llr data to pltf %i dev %i\n" , (int)rt, 0,0); + return MAX_ITERATION; + +} diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl new file mode 100644 index 0000000000..d5e2fa5695 --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl @@ -0,0 +1,302 @@ +/* + * 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.0 (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 + */ + +/*! \file PHY/CODING/nrLDPC_decoder_kernels_CL.cl +* \brief kernel functions for ldpc decoder accelerated via openCL +* \author Francois TABURET +* \date 2021 +* \version 1.0 +* \company Nokia BellLabs France +* \email: francois.taburet@nokia-bell-labs.com +* \note initial implem - translation of cuda version +* \warning +*/ +#define define MAX_ITERATION 2 +#define MC 1 + +#define INT32_MAX 2147483647 + +typedef struct{ + char x; + char y; + short value; +} h_element; + +//__global char dev_dt [46*68*384]; +//__local char *dev_t; +//__global char dev_llr[68*384]; +//__global unsigned char dev_tmp[68*384]; + + + + +//__constant h_element dev_h_compact1[46*19] = {}; // used in kernel 1 +//__constant h_element dev_h_compact2[68*30] = {}; // used in kernel 2 + +// __device__ __constantant__ h_element dev_h_compact1[46*19]; // used in kernel 1 +// __device__ __constantant__ h_element dev_h_compact2[68*30]; // used in kernel 2 + +// row and col element count +__constant char h_ele_row_bg1_count[46] = { + 19, 19, 19, 19, 3, 8, 9, 7, 10, 9, + 7, 8, 7, 6, 7, 7, 6, 6, 6, 6, + 6, 6, 5, 5, 6, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, + 4, 5, 4, 5, 5, 4}; +__constant char h_ele_col_bg1_count[68] = { + 30, 28, 7, 11, 9, 4, 8, 12, 8, 7, + 12, 10, 12, 11, 10, 7, 10, 10, 13, 7, + 8, 11, 12, 5, 6, 6, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1}; +__constant char h_ele_row_bg2_count[42] = { + 8, 10, 8, 10, 4, 6, 6, 6, 4, 5, + 5, 5, 4, 5, 5, 4, 5, 5, 4, 4, + 4, 4, 3, 4, 4, 3, 5, 3, 4, 3, + 5, 3, 4, 4, 4, 4, 4, 3, 4, 4, + 4, 4}; +__constant char h_ele_col_bg2_count[52] = { + 22, 23, 10, 5, 5, 14, 7, 13, 6, 8, + 9, 16, 9, 12, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1}; + + + +// Kernel 1 +__kernel void ldpc_cnp_kernel_1st_iter( __global char * dev_llr, __global char * dev_dt, __local h_element *dev_h_compact1, int BG, int row, int col, int Zc) +{ +// int iMCW = blockIdx.y; // codeword id +// int iBlkRow = blockIdx.x; // block row in h_base +// int iSubRow = threadIdx.x; // row index in sub_block of h_base +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("cnp %d\n", threadIdx.x); + int iMCW = get_group_id(1); // codeword id + int iBlkRow = get_group_id(0); // block row in h_base + int iBlkCol; // block col in h_base + int iSubRow = get_local_id(0);; // row index in sub_block of h_base + int iCol; // overall col index in h_base + int offsetR; + int shift_t; + +// For 2-min algorithm. + int Q_sign = 0; + int sq; + int Q, Q_abs; + int R_temp; + + int sign = 1; + int rmin1 = INT32_MAX; + int rmin2 = INT32_MAX; + char idx_min = 0; + + h_element h_element_t; + int s = (BG==1)? h_ele_row_bg1_count[iBlkRow]:h_ele_row_bg2_count[iBlkRow]; + offsetR = (iMCW * row*col*Zc) + iBlkRow * Zc + iSubRow; // row*col*Zc = size of dev_dt +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("s: %d, offset %d\n", s, offsetR); +// The 1st recursion + for(int i = 0; i < s; i++) // loop through all the ZxZ sub-blocks in a row + { + h_element_t = dev_h_compact1[i*row+iBlkRow]; // compact_col == row + + iBlkCol = h_element_t.y; + shift_t = h_element_t.value; + + shift_t = (iSubRow + shift_t) % Zc; + iCol = (iMCW * col*Zc) + iBlkCol * Zc + shift_t; // col*Zc = size of llr + Q = dev_llr[iCol]; + Q_abs = (Q>0)? Q : -Q; + sq = Q < 0; +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("i %d, icol %d, Q: %d\n", i, iCol, Q); + // quick version + sign = sign * (1 - sq * 2); + Q_sign |= sq << i; + + if (Q_abs < rmin1){ + rmin2 = rmin1; + rmin1 = Q_abs; + idx_min = i; + } else if (Q_abs < rmin2){ + rmin2 = Q_abs; + } + } + +// if(blockIdx.x == 0 && threadIdx.x == 1)printf("min1 %d, min2 %d, min1_idx %d\n", rmin1, rmin2, idx_min); + +// The 2nd recursion + for(int i = 0; i < s; i++){ + // v0: Best performance so far. 0.75f is the value of alpha. + sq = 1 - 2 * ((Q_sign >> i) & 0x01); + R_temp = 0.75f * sign * sq * (i != idx_min ? rmin1 : rmin2); + // write results to global memory + h_element_t = dev_h_compact1[i*row+iBlkRow]; + int addr_temp = offsetR + h_element_t.y * row * Zc; + dev_dt[addr_temp] = R_temp; +// if(blockIdx.x == 0 && threadIdx.x == 1)printf("R_temp %d, temp_addr %d\n", R_temp, addr_temp); + } +} + +// Kernel_1 +__kernel void ldpc_cnp_kernel( __global char * dev_llr, __global char * dev_dt, __local h_element *dev_h_compact1, int BG, int row, int col, int Zc) +{ +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("cnp\n"); +// int iMCW = blockIdx.y; +// int iBlkRow = blockIdx.x; // block row in h_base // block col in h_base +// int iSubRow = threadIdx.x; // row index in sub_block of h_base + int iMCW = get_group_id(1); + int iBlkRow = get_group_id(0); // block row in h_base + int iBlkCol; // block col in h_base + int iSubRow = get_local_id(0);; // row index in sub_block of h_base + int iCol; // overall col index in h_base + int offsetR; + int shift_t; + +// For 2-min algorithm. + int Q_sign = 0; + int sq; + int Q, Q_abs; + int R_temp; + + int sign = 1; + int rmin1 = INT32_MAX; + int rmin2 = INT32_MAX; + char idx_min = 0; + + h_element h_element_t; + int s = (BG==1)? h_ele_row_bg1_count[iBlkRow]: h_ele_row_bg2_count[iBlkRow]; + offsetR = (iMCW *row*col*Zc) + iBlkRow * Zc + iSubRow; // row * col * Zc = size of dev_dt +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("s: %d, offset %d\n", s, offsetR); +// The 1st recursion + for(int i = 0; i < s; i++) // loop through all the ZxZ sub-blocks in a row + { + h_element_t = dev_h_compact1[i*row+iBlkRow]; + + iBlkCol = h_element_t.y; + shift_t = h_element_t.value; + shift_t = (iSubRow + shift_t) % Zc; + iCol = iBlkCol * Zc + shift_t; + + R_temp = dev_dt[offsetR + iBlkCol * row * Zc]; + + Q = dev_llr[iMCW * (col*Zc) + iCol] - R_temp; + Q_abs = (Q>0)? Q : -Q; +// if(blockIdx.x == 0 && threadIdx.x == 1) printf("i %d, icol %d, Q: %d\n", i, iCol, Q); + sq = Q < 0; + sign = sign * (1 - sq * 2); + Q_sign |= sq << i; + + if (Q_abs < rmin1){ + rmin2 = rmin1; + rmin1 = Q_abs; + idx_min = i; + } else if (Q_abs < rmin2){ + rmin2 = Q_abs; + } + + } + +// if(blockIdx.x == 0 && threadIdx.x == 1)printf("min1 %d, min2 %d, min1_idx %d\n", rmin1, rmin2, idx_min); + +// The 2nd recursion + for(int i = 0; i < s; i ++){ + sq = 1 - 2 * ((Q_sign >> i) & 0x01); + R_temp = 0.75f * sign * sq * (i != idx_min ? rmin1 : rmin2); + + + // write results to global memory + h_element_t = dev_h_compact1[i*row+iBlkRow]; + int addr_temp = h_element_t.y * row * Zc + offsetR; + dev_dt[addr_temp] = R_temp; +// if(blockIdx.x == 0 && threadIdx.x == 1)printf("R_temp %d, temp_addr %d\n", R_temp, addr_temp); + } +} + +// Kernel 2: VNP processing +__kernel void +ldpc_vnp_kernel_normal(__global char * dev_llr, __global char * dev_dt, __global char * dev_const_llr, __local h_element *dev_h_compact2, int BG, int row, int col, int Zc) +{ +// int iMCW = blockIdx.y; +// int iBlkCol = blockIdx.x; +// int iSubCol = threadIdx.x; + int iMCW = get_group_id(1); + int iBlkCol = get_group_id(0); + int iBlkRow; + int iSubCol = get_local_id(0); + int iRow; + int iCol; + + int shift_t, sf; + int APP; + + h_element h_element_t; + + // update all the llr values + iCol = iBlkCol * Zc + iSubCol; + APP = dev_const_llr[iMCW *col*Zc + iCol]; + int offsetDt = iMCW *row*col*Zc + iBlkCol * row * Zc; + int s = (BG==1)? h_ele_col_bg1_count[iBlkCol]:h_ele_col_bg2_count[iBlkCol]; + + for(int i = 0; i < s; i++) + { + h_element_t = dev_h_compact2[i*col+iBlkCol]; + + shift_t = h_element_t.value%Zc; + iBlkRow = h_element_t.x; + + sf = iSubCol - shift_t; + sf = (sf + Zc) % Zc; + + iRow = iBlkRow * Zc + sf; + APP = APP + dev_dt[offsetDt + iRow]; + } + if(APP > SCHAR_MAX) APP = SCHAR_MAX; + if(APP < SCHAR_MIN) APP = SCHAR_MIN; + // write back to device global memory + dev_llr[iMCW *col*Zc + iCol] = APP; +} + + +__kernel void pack_decoded_bit(__global unsigned char * dev_llr, __global unsigned char * dev_tmp, int col, int Zc) +{ +// int iMCW = blockIdx.y; +// int btid = threadIdx.x; + unsigned char tmp[128]; + int iMCW = get_group_id(1); + int btid = get_local_id(0); + int tid = iMCW * col*Zc + get_group_id(0)*128 + btid; + tmp[btid] = 0; + + if(dev_llr[tid] < 0){ + tmp[btid] = 1 << (7-(btid&7)); + } +// __syncthreads(); + + if(btid < 16){ + dev_tmp[iMCW * col*Zc + get_group_id(0)*16+btid] = 0; + for(int i = 0; i < 8; i++){ + dev_tmp[iMCW * col*Zc + get_group_id(0)*16+btid] += tmp[btid*8+i]; + } + } +} + diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index e5b99246d5..99b6f75f93 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -70,6 +70,7 @@ typedef struct nrLDPC_dec_params { uint16_t Z; /**< Lifting size */ uint8_t R; /**< Decoding rate: Format 15,13,... for code rates 1/5, 1/3,... */ uint8_t numMaxIter; /**< Maximum number of iterations */ + int block_length; e_nrLDPC_outMode outMode; /**< Output format */ } t_nrLDPC_dec_params; diff --git a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu index 931d500338..72517edcdd 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu +++ b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu @@ -7,14 +7,14 @@ * \note * \warning */ - +#include #include #include #include #include #include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPCdecoder_defs.h" - +#include "assertions.h" #include "bgs/BG1_I0" #include "bgs/BG1_I1" #include "bgs/BG1_I2" @@ -462,10 +462,11 @@ void read_BG(int BG, int *h, int row, int col) } extern "C" -void init_LLR_DMA_for_CUDA(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, int block_length){ +void init_LLR_DMA(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out){ uint16_t Zc = p_decParams->Z; uint8_t BG = p_decParams->BG; + int block_length = p_decParams->block_length; uint8_t row,col; if(BG == 1){ row = 46; @@ -483,14 +484,60 @@ void init_LLR_DMA_for_CUDA(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8 } +using namespace std ; + +/* from here: entry points in decoder shared lib */ extern "C" -int32_t nrLDPC_decoder_LYC(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, int block_length, time_stats_t *time_decoder) +int ldpc_autoinit(void) { // called by the library loader +/*int devices = 0; + + cudaError_t err = cudaGetDeviceCount(&devices); + AssertFatal(devices>0,"\nNo cuda GPU found\n\n"); + + const int kb = 1024; + const int mb = kb * kb; + wcout << "NBody.GPU" << endl << "=========" << endl << endl; + + wcout << "CUDA version: v" << CUDART_VERSION << endl; + + + wcout << "CUDA Devices: " << endl << endl; + + for(int i = 0; i < devices; ++i) + { + cudaDeviceProp props; + cudaGetDeviceProperties(&props, i); + wcout << i << ": " << props.name << ": " << props.major << "." << props.minor << endl; + wcout << " Global memory: " << props.totalGlobalMem / mb << "mb" << endl; + wcout << " Shared memory: " << props.sharedMemPerBlock / kb << "kb" << endl; + wcout << " Constant memory: " << props.totalConstMem / kb << "kb" << endl; + wcout << " Block registers: " << props.regsPerBlock << endl << endl; + + wcout << " Warp size: " << props.warpSize << endl; + wcout << " Threads per block: " << props.maxThreadsPerBlock << endl; + wcout << " Max block dimensions: [ " << props.maxThreadsDim[0] << ", " << props.maxThreadsDim[1] << ", " << props.maxThreadsDim[2] << " ]" << endl; + wcout << " Max grid dimensions: [ " << props.maxGridSize[0] << ", " << props.maxGridSize[1] << ", " << props.maxGridSize[2] << " ]" << endl; + wcout << endl; + } +*/ + warmup_for_GPU(); + return 0; +} + +extern "C" +void nrLDPC_initcall(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out) { + set_compact_BG(p_decParams->Z,p_decParams->BG); + init_LLR_DMA(p_decParams, p_llr, p_out); +} + + +extern "C" +int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out,t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats *time_decoder) { - - uint16_t Zc = p_decParams->Z; uint8_t BG = p_decParams->BG; uint8_t numMaxIter = p_decParams->numMaxIter; + int block_length = p_decParams->block_length; e_nrLDPC_outMode outMode = p_decParams->outMode; cudaError_t cudaStatus; uint8_t row,col; diff --git a/openair1/PHY/CODING/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_defs.h index b96067f4b6..321ecaab7d 100644 --- a/openair1/PHY/CODING/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_defs.h @@ -45,6 +45,7 @@ typedef struct { time_stats_t *toutput; }encoder_implemparams_t; #define INIT0_LDPCIMPLEMPARAMS {0,0,0,NULL,NULL,NULL,NULL} +typedef void(*nrLDPC_initcallfunc_t)(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out); typedef int(*nrLDPC_encoderfunc_t)(unsigned char **,unsigned char **,int,int,short, short, encoder_implemparams_t*); //============================================================================================================================ // decoder interface @@ -56,4 +57,4 @@ typedef int(*nrLDPC_encoderfunc_t)(unsigned char **,unsigned char **,int,int,sho \param p_profiler LDPC profiler statistics */ typedef int32_t(*nrLDPC_decoderfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_procBuf* , t_nrLDPC_time_stats* ); -#endif \ No newline at end of file +#endif diff --git a/openair1/PHY/CODING/nrLDPC_extern.h b/openair1/PHY/CODING/nrLDPC_extern.h index c0bfa0fdd8..b75b38fc76 100644 --- a/openair1/PHY/CODING/nrLDPC_extern.h +++ b/openair1/PHY/CODING/nrLDPC_extern.h @@ -23,13 +23,16 @@ #ifdef LDPC_LOADER nrLDPC_decoderfunc_t nrLDPC_decoder; nrLDPC_encoderfunc_t nrLDPC_encoder; +nrLDPC_initcallfunc_t nrLDPC_initcall; #else /* functions to load the LDPC shared lib, implemented in openair1/PHY/CODING/nrLDPC_load.c */ -extern int load_nrLDPClib(void) ; +extern int load_nrLDPClib(char *version) ; extern int load_nrLDPClib_ref(char *libversion, nrLDPC_encoderfunc_t * nrLDPC_encoder_ptr); // for ldpctest /* ldpc coder/decoder functions, as loaded by load_nrLDPClib(). */ +extern nrLDPC_initcallfunc_t nrLDPC_initcall; + extern nrLDPC_decoderfunc_t nrLDPC_decoder; extern nrLDPC_encoderfunc_t nrLDPC_encoder; // inline functions: #include "openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h" -#endif \ No newline at end of file +#endif diff --git a/openair1/PHY/CODING/nrLDPC_load.c b/openair1/PHY/CODING/nrLDPC_load.c index a74bdf7bd1..23e5032bad 100644 --- a/openair1/PHY/CODING/nrLDPC_load.c +++ b/openair1/PHY/CODING/nrLDPC_load.c @@ -42,22 +42,32 @@ /* function description array, to be used when loading the encoding/decoding shared lib */ -static loader_shlibfunc_t shlib_fdesc[2]; +static loader_shlibfunc_t shlib_fdesc[3]; -char *arg[64]={"ldpctest","-O","cmdlineonly::dbgl0"}; +/* arguments used when called from phy simulators exec's which do not use the config module */ +/* arg is used to initialize the config module so that the loader works as expected */ +char *arg[64]={"ldpctest","-O","cmdlineonly::dbgl0",NULL,NULL}; -int load_nrLDPClib(void) { +int load_nrLDPClib(char *version) { char *ptr = (char*)config_get_if(); + char libname[64]="ldpc"; + if ( ptr==NULL ) {// phy simulators, config module possibly not loaded - load_configmodule(3,(char **)arg,CONFIG_ENABLECMDLINEONLY) ; + load_configmodule(0,(char **)NULL,CONFIG_ENABLECMDLINEONLY) ; logInit(); } shlib_fdesc[0].fname = "nrLDPC_decod"; shlib_fdesc[1].fname = "nrLDPC_encod"; - int ret=load_module_shlib("ldpc",shlib_fdesc,sizeof(shlib_fdesc)/sizeof(loader_shlibfunc_t),NULL); + shlib_fdesc[2].fname = "nrLDPC_initcall"; + int ret; + if (version) + ret=load_module_version_shlib(libname,version,shlib_fdesc,sizeof(shlib_fdesc)/sizeof(loader_shlibfunc_t),NULL); + else + ret=load_module_shlib(libname,shlib_fdesc,sizeof(shlib_fdesc)/sizeof(loader_shlibfunc_t),NULL); AssertFatal( (ret >= 0),"Error loading ldpc decoder"); nrLDPC_decoder = (nrLDPC_decoderfunc_t)shlib_fdesc[0].fptr; nrLDPC_encoder = (nrLDPC_encoderfunc_t)shlib_fdesc[1].fptr; + nrLDPC_initcall = (nrLDPC_initcallfunc_t)shlib_fdesc[2].fptr; return 0; } @@ -65,10 +75,8 @@ int load_nrLDPClib_ref(char *libversion, nrLDPC_encoderfunc_t * nrLDPC_encoder_p loader_shlibfunc_t shlib_encoder_fdesc; shlib_encoder_fdesc.fname = "nrLDPC_encod"; - char libpath[64]; - sprintf(libpath,"ldpc%s",libversion); - int ret=load_module_shlib(libpath,&shlib_encoder_fdesc,1,NULL); - AssertFatal( (ret >= 0),"Error loading ldpc encoder %s\n",libpath); + int ret=load_module_version_shlib("ldpc",libversion,&shlib_encoder_fdesc,1,NULL); + AssertFatal( (ret >= 0),"Error loading ldpc encoder %s\n",(libversion==NULL)?"":libversion); *nrLDPC_encoder_ptr = (nrLDPC_encoderfunc_t)shlib_encoder_fdesc.fptr; return 0; } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index e61b3dff9b..1dfaed8b94 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -258,10 +258,11 @@ static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void // handle rate matching with a single 128 bit word using bit shuffling // can be done with SIMD intrisics if needed if (polarParams->groupsize < 8) { - AssertFatal(polarParams->encoderLength<=128,"Need to handle groupsize<8 and N>128\n"); + AssertFatal(polarParams->encoderLength<=512,"Need to handle groupsize(%d)<8 and N(%d)>512\n",polarParams->groupsize,polarParams->encoderLength); uint128_t *out128=(uint128_t*)out; uint128_t *in128=(uint128_t*)in; - *out128=0; + for (int i=0;iencoderLength>>7;i++) + out128[i]=0; uint128_t tmp0; #ifdef DEBUG_POLAR_ENCODER uint128_t tmp1; @@ -270,15 +271,21 @@ static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void #ifdef DEBUG_POLAR_ENCODER printf("%d<-%u : %llx.%llx =>",i,polarParams->rate_matching_pattern[i],((uint64_t *)out)[1],((uint64_t *)out)[0]); #endif - tmp0 = (*in128&(((uint128_t)1)<rate_matching_pattern[i])); + uint8_t pi=polarParams->rate_matching_pattern[i]; + uint8_t pi7=pi>>7; + uint8_t pimod128=pi&127; + uint8_t imod128=i&127; + uint8_t i7=i>>7; + + tmp0 = (in128[pi7]&(((uint128_t)1)<<(pimod128))); + if (tmp0!=0) { - *out128 = *out128 | ((uint128_t)1)<%llx.%llx => %llx.%llx\n", - ((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0], - ((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0], - ((uint64_t *)out)[1],((uint64_t *)out)[0]); + printf("%llx.%llx<->%llx.%llx => %llx.%llx\n", + ((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0], + ((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0], + ((uint64_t *)out)[1],((uint64_t *)out)[0]); #endif } } diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index 1d80a83131..0eede23766 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -92,9 +92,7 @@ if ((Kprime%Kb) > 0) else Z = (Kprime/Kb); -#ifdef DEBUG_SEGMENTATION - printf("nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z); -#endif + LOG_D(PHY,"nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z); if (Z <= 2) { *K = 2; @@ -148,10 +146,8 @@ else *F = ((*K) - Kprime); -#ifdef DEBUG_SEGMENTATION - printf("final nr seg output Z %u K %u F %u \n", *Zout, *K, *F); - printf("C %u, K %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*K,Bprime>>3,Bprime,*F); -#endif + LOG_D(PHY,"final nr seg output Z %u K %u F %u \n", *Zout, *K, *F); + LOG_D(PHY,"C %u, K %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*K,Bprime>>3,Bprime,*F); if ((input_buffer) && (output_buffers)) { diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 32e190679d..cd4848ea8c 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -21,6 +21,7 @@ #include "executables/nr-softmodem-common.h" #include "common/utils/nr/nr_common.h" +#include "common/ran_context.h" #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" #include "PHY/NR_REFSIG/nr_refsig.h" @@ -35,7 +36,6 @@ #include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" #include "openair1/PHY/CODING/nrLDPC_extern.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "assertions.h" #include @@ -108,7 +108,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, crcTableInit(); init_scrambling_luts(); init_pucch2_luts(); - load_nrLDPClib(); + load_nrLDPClib(NULL); // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); //PDCCH DMRS init @@ -124,6 +124,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (int symb=0; symbsymbols_per_slot; symb++) { pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + LOG_D(PHY,"pdcch_dmrs[%d][%d] %p\n",slot,symb,pdcch_dmrs[slot][symb]); AssertFatal(pdcch_dmrs[slot][symb]!=NULL, "NR init: pdcch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); } } @@ -518,45 +519,38 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { LOG_I(PHY,"gNB %d configured\n",Mod_id); } - -void init_nr_transport(PHY_VARS_gNB *gNB) { - int i; - int j; +void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; - LOG_I(PHY, "Initialise nr transport\n"); uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value; + msg->num_pdsch_slot = 0; + + for (int i=0; inumber_of_nr_dlsch_max; i++) { + LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,gNB->number_of_nr_dlsch_max); + for (int j=0; j<2; j++) { + msg->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); + AssertFatal(msg->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i); + } + } +} + +void init_nr_transport(PHY_VARS_gNB *gNB) { + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + LOG_I(PHY, "Initialise nr transport\n"); memset(gNB->num_pdsch_rnti, 0, sizeof(uint16_t)*80); - for (i=0; i pdcch_pdu[i].frame=-1; - LOG_I(PHY,"Initializing UL PDCCH list for UL PDCCH %d/%d\n",i,NUMBER_OF_NR_PDCCH_MAX); - gNB->ul_pdcch_pdu[i].frame=-1; - } - - for (i=0; ipucch[i] = new_gNB_pucch(); AssertFatal(gNB->pucch[i]!=NULL,"Can't initialize pucch %d \n", i); } - for (i=0; inumber_of_nr_dlsch_max; i++) { - - LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,gNB->number_of_nr_dlsch_max); - - for (j=0; j<2; j++) { - gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); - AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i); - } - } - - for (i=0; inumber_of_nr_ulsch_max; i++) { + for (int i=0; inumber_of_nr_ulsch_max; i++) { LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); - for (j=0; j<2; j++) { + for (int j=0; j<2; j++) { // ULSCH for data gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL, 0); diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 097c2b3ad2..4024ed1617 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -60,10 +60,12 @@ int nr_phy_init_RU(RU_t *ru) { for (i=0; inb_tx; i++) { // Allocate 10 subframes of I/Q TX signal data (time) if not - ru->common.txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_frame*sizeof(int32_t) ); + ru->common.txdata[i] = (int32_t*)malloc16_clear( ru->sf_extension + (fp->samples_per_frame*sizeof(int32_t) )); + LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes,sf_extension %d)\n",i,ru->common.txdata[i], + (ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t),ru->sf_extension); + ru->common.txdata[i] = &ru->common.txdata[i][ru->sf_extension]; - LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes)\n",i,ru->common.txdata[i], - fp->samples_per_frame*sizeof(int32_t)); + LOG_I(PHY,"[INIT] common.txdata[%d] = %p \n",i,ru->common.txdata[i]); } for (i=0;inb_rx;i++) { @@ -100,8 +102,8 @@ int nr_phy_init_RU(RU_t *ru) { // allocate FFT output buffers (RX) ru->common.rxdataF = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); for (i=0; inb_rx; i++) { - // allocate 2 subframes of I/Q signal data (frequency) - ru->common.rxdataF[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->samples_per_subframe_wCP) ); + // allocate 4 slots of I/Q signal data (frequency) + ru->common.rxdataF[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(4*fp->symbols_per_slot*fp->ofdm_symbol_size) ); LOG_I(PHY,"rxdataF[%d] %p for RU %d\n",i,ru->common.rxdataF[i],ru->idx); } @@ -176,7 +178,11 @@ void nr_phy_free_RU(RU_t *ru) free_and_zero(ru->frame_parms); if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals - for (i = 0; i < ru->nb_tx; i++) free_and_zero(ru->common.txdata[i]); + int32_t *ptr; + for (i = 0; i < ru->nb_tx; i++) { + ptr=&ru->common.txdata[i][-ru->sf_extension]; + free_and_zero(ptr); + } for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdata[i]); free_and_zero(ru->common.txdata); free_and_zero(ru->common.rxdata); diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 98e3c5a1a3..0920da667d 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -22,7 +22,6 @@ #include "phy_init.h" #include "common/utils/nr/nr_common.h" #include "common/utils/LOG/log.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" /// Subcarrier spacings in Hz indexed by numerology index uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3}; @@ -102,7 +101,7 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, int N_RB_DL) if (fp->nr_band == 5 || fp->nr_band == 66) fp->ssb_type = nr_ssb_type_B; else{ - if (fp->nr_band == 41 || ( fp->nr_band > 76 && fp->nr_band < 80) ) + if (fp->nr_band == 41 || fp->nr_band == 38 || ( fp->nr_band > 76 && fp->nr_band < 80) ) fp->ssb_type = nr_ssb_type_C; else AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->nr_band, mu); @@ -141,6 +140,8 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, int N_RB_DL) fp->first_carrier_offset = fp->ofdm_symbol_size - (N_RB_DL * 12 / 2); fp->nb_prefix_samples = fp->ofdm_symbol_size / 128 * 9; fp->nb_prefix_samples0 = fp->ofdm_symbol_size / 128 * (9 + (1 << mu)); + LOG_I(PHY,"Init: N_RB_DL %d, first_carrier_offset %d, nb_prefix_samples %d,nb_prefix_samples0 %d\n", + N_RB_DL,fp->first_carrier_offset,fp->nb_prefix_samples,fp->nb_prefix_samples0); } uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp) diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 85101a3080..dd9232de83 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -409,6 +409,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB); void init_dfts(void); void fill_subframe_mask(PHY_VARS_eNB *eNB); +void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg); /** @} */ #endif diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index e2bec337aa..86723d0fed 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -31,15 +31,14 @@ */ #include +#include "PHY/defs_eNB.h" +#include "PHY/defs_gNB.h" #include #include "PHY/defs_RU.h" #include "PHY/TOOLS/alaw_lut.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" #include "common/utils/LOG/vcd_signal_dumper.h" -//#define DEBUG_DL_MOBIPASS -//#define DEBUG_UL_MOBIPASS -#define SUBFRAME_SKIP_NUM_MOBIPASS 8 const uint8_t lin2alaw_if5[65536] = {213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, @@ -1050,18 +1049,12 @@ static inline int64_t clock_difftime_ns(struct timespec start, struct timespec e return temp_ns; } -void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) { +void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int tti, uint8_t *seqno, uint16_t packet_type) { LTE_DL_FRAME_PARMS *fp=ru->frame_parms; int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; int32_t *tx_buffer=NULL; -#ifdef DEBUG_DL_MOBIPASS - int8_t dummy_buffer[fp->samples_per_tti*2]; -#endif - void *alaw_buffer = ru->ifbuffer.tx[subframe&1]; - uint16_t *data_block = NULL; - uint16_t *j = NULL; - uint16_t packet_id=0, i=0, element_id=0; + uint16_t packet_id=0, i=0; uint32_t spp_eth = (uint32_t) ru->ifdevice.openair0_cfg->samples_per_packet; uint32_t spsf = (uint32_t) ru->ifdevice.openair0_cfg->samples_per_frame/10; @@ -1072,6 +1065,12 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t if (eth->compression == ALAW_COMPRESS) { AssertFatal(1==0,"IF5 compression needs reworking\n"); /* + void *alaw_buffer = ru->ifbuffer.tx[subframe&1]; + int element_id=0; + + uint16_t *data_block = NULL; + uint16_t *j = NULL; + if (eth->flags == ETH_RAW_MODE) { data_block = (uint16_t*)(alaw_buffer + APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES); } else { @@ -1105,10 +1104,22 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t */ } else if (eth->compression == NO_COMPRESS) { + NR_DL_FRAME_PARMS *nrfp = ru->nr_frame_parms; + + int offset,siglen; + if (nrfp) { + offset = nrfp->get_samples_slot_timestamp(tti,nrfp,0); + siglen = nrfp->get_samples_per_slot(tti,nrfp); + } + else { + offset = tti*fp->samples_per_subframe; + siglen = spsf; + } + for (i=0; i < ru->nb_tx; i++) - txp[i] = (int32_t*)&ru->common.txdata[i][subframe*fp->samples_per_tti]; + txp[i] = (int32_t*)&ru->common.txdata[i][offset]; - for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) { + for (packet_id=0; packet_id < siglen / spp_eth; packet_id++) { for (int aid=0; aidnb_tx;aid++) { //VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF5_PKT_ID, packet_id ); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF0, 1 ); @@ -1119,9 +1130,9 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t spp_eth, aid, 0); - LOG_D(HW,"SF %d : packet %d, TS %llu\n",subframe,packet_id,(unsigned long long)(proc_timestamp+packet_id*spp_eth)); + LOG_D(HW,"TTI %d : packet %d, TS %llu\n",tti,packet_id,(unsigned long long)(proc_timestamp-ru->ts_offset+packet_id*spp_eth)); clock_gettime( CLOCK_MONOTONIC, &end_comp); - LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp)); + LOG_D(HW,"[TTI %d] IF_Write_Time: %"PRId64"\n",tti,clock_difftime_ns(start_comp, end_comp)); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF0, 0 ); txp[aid] += spp_eth; @@ -1130,7 +1141,8 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t } } else if (packet_type == IF5_RRH_GW_UL) { if (eth->compression == ALAW_COMPRESS) { - if (eth->flags == ETH_RAW_MODE) { + AssertFatal(1==0,"ALAW IF5 requires work\n"); + /* if (eth->flags == ETH_RAW_MODE) { data_block = (uint16_t*)(alaw_buffer + APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES); } else { data_block = (uint16_t*)(alaw_buffer + APP_HEADER_SIZE_BYTES); @@ -1160,9 +1172,10 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp)); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF0, 0 ); } +*/ } else if (eth->compression == NO_COMPRESS) { for (i=0; i < fp->nb_antennas_rx; i++) - rxp[i] = (void*)&ru->common.rxdata[i][subframe*fp->samples_per_tti]; + rxp[i] = (void*)&ru->common.rxdata[i][tti*fp->samples_per_tti]; for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF5_PKT_ID, packet_id ); @@ -1175,153 +1188,28 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t fp->nb_antennas_rx, 0); clock_gettime( CLOCK_MONOTONIC, &end_comp); - LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp)); + LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",tti,clock_difftime_ns(start_comp, end_comp)); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF0, 0 ); for (i=0; i < fp->nb_antennas_rx; i++) rxp[i] += spp_eth; } } - } else if (packet_type == IF5_MOBIPASS) { - /* the only difference between mobipass standalone and the other one - * is the timestamp in trx_write_func, but let's duplicate anyway - * (plus we don't call malloc for the standalone case) - */ - if (ru->if_timing == synch_to_mobipass_standalone) { - uint16_t db_fulllength = PAYLOAD_MOBIPASS_NUM_SAMPLES; - - __m128i *data_block=NULL, *data_block_head=NULL; - __m128i *txp128; - __m128i t0, t1; - - unsigned char _tx_buffer[MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)]; - tx_buffer=(int32_t *)_tx_buffer; - - IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES); - data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t); - - header->flags = 0; - header->fifo_status = 0; - header->seqno = *seqno; - header->ack = 0; - header->word0 = 0; - - txp[0] = (void*)&ru->common.txdata[0][subframe*ru->frame_parms->samples_per_tti]; - txp128 = (__m128i *) txp[0]; - - for (packet_id=0; packet_idsamples_per_tti/db_fulllength; packet_id++) { - header->time_stamp = htonl((uint32_t)(proc_timestamp + packet_id*db_fulllength)); - data_block = data_block_head; - - for (i=0; i>2; i+=2) { - t0 = _mm_srai_epi16(*txp128++, 4); - t1 = _mm_srai_epi16(*txp128++, 4); - _mm_storeu_si128(data_block++, _mm_packs_epi16(t0, t1)); - } - - // Write the packet to the fronthaul - if ((ru->ifdevice.trx_write_func(&ru->ifdevice, - proc_timestamp + packet_id*db_fulllength, - (void**)&tx_buffer, - db_fulllength, - 1, - IF5_MOBIPASS)) < 0) { - perror("ETHERNET write for IF5_MOBIPASS\n"); - } - header->seqno += 1; - } - *seqno = header->seqno; - tx_buffer = NULL; - } else { - uint16_t db_fulllength = PAYLOAD_MOBIPASS_NUM_SAMPLES; - - __m128i *data_block=NULL, *data_block_head=NULL; - - __m128i *txp128; - __m128i t0, t1; - - // tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); - tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); - IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES); - data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t); - - header->flags = 0; - header->fifo_status = 0; - header->seqno = *seqno; - header->ack = 0; - header->word0 = 0; - - txp[0] = (void*)&ru->common.txdata[0][subframe*ru->frame_parms->samples_per_tti]; - txp128 = (__m128i *) txp[0]; - - for (packet_id=0; packet_idsamples_per_tti/db_fulllength; packet_id++) { - header->time_stamp = htonl((uint32_t)(proc_timestamp + packet_id*db_fulllength)); - data_block = data_block_head; - - for (i=0; i>2; i+=2) { - t0 = _mm_srai_epi16(*txp128++, 4); - t1 = _mm_srai_epi16(*txp128++, 4); -// *data_block++ = _mm_packs_epi16(t0, t1); - _mm_storeu_si128(data_block++, _mm_packs_epi16(t0, t1)); - } - - // Write the packet to the fronthaul - if ((ru->ifdevice.trx_write_func(&ru->ifdevice, - packet_id, - (void**)&tx_buffer, - db_fulllength, - 1, - IF5_MOBIPASS)) < 0) { - perror("ETHERNET write for IF5_MOBIPASS\n"); - } - -#ifdef DEBUG_DL_MOBIPASS - if ((subframe==0)&&(dummy_cnt == 100)) { - memcpy((void*)&dummy_buffer[packet_id*db_fulllength*2],(void*)data_block_head,db_fulllength*2); - } -#endif - header->seqno += 1; - } - *seqno = header->seqno; - -#ifdef DEBUG_DL_MOBIPASS - uint8_t txe; - txe = dB_fixed(signal_energy(txp[0],fp->samples_per_tti)); - if (txe > 0){ - LOG_D(PHY,"[Mobipass] frame:%d, subframe:%d, energy %d\n", (proc_timestamp/(10*fp->samples_per_tti))&1023,subframe, txe); - } -#endif - } } else { AssertFatal(1==0, "send_IF5 - Unknown packet_type %x", packet_type); } free(tx_buffer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 ); -#ifdef DEBUG_DL_MOBIPASS - if(subframe==0) { - if (dummy_cnt==100) { - LOG_M("txsigmb.m","txs",(void*)dummy_buffer, fp->samples_per_tti,1, 5); - exit(-1); - } else { - dummy_cnt++; - } - } -#endif return; } - -void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16_t packet_type) { +void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t packet_type) { LTE_DL_FRAME_PARMS *fp=ru->frame_parms; int32_t *txp[ru->nb_tx], *rxp[ru->nb_rx]; uint16_t packet_id=0, i=0; -#ifdef DEBUG_UL_MOBIPASS - //int8_t dummy_buffer_rx[fp->samples_per_tti*2]; - uint8_t rxe; -#endif int32_t spp_eth = (int32_t) ru->ifdevice.openair0_cfg->samples_per_packet; @@ -1375,6 +1263,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16 } */ } else if (eth->compression == NO_COMPRESS) { + int subframe = tti; for (i=0; i < fp->nb_antennas_tx; i++) txp[i] = (void*)&ru->common.txdata[i][subframe*fp->samples_per_tti]; @@ -1433,14 +1322,25 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16 } */ } else if (eth->compression == NO_COMPRESS) { - int16_t temp_rx[spp_eth*2] __attribute__((aligned(32))); + int16_t temp_rx[spp_eth*2] __attribute__((aligned(32))); + NR_DL_FRAME_PARMS *nrfp = ru->nr_frame_parms; + + int offset,siglen; + if (nrfp) { + offset = nrfp->get_samples_slot_timestamp(tti,nrfp,0); + siglen = nrfp->get_samples_per_slot(tti,nrfp); + } + else { + offset = tti*fp->samples_per_subframe; + siglen = spsf; + } for (i=0; i < ru->nb_rx; i++) - rxp[i] = &ru->common.rxdata[i][subframe*fp->samples_per_tti]; + rxp[i] = &ru->common.rxdata[i][offset]; int aid; int firstTS=1; openair0_timestamp oldTS=0; - for (packet_id=0; packet_id < ru->nb_rx*spsf / spp_eth; packet_id++) { + for (packet_id=0; packet_id < ru->nb_rx*siglen / spp_eth; packet_id++) { //VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF5_PKT_ID, packet_id ); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF0, 1 ); clock_gettime( CLOCK_MONOTONIC, &if_time); @@ -1453,7 +1353,8 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16 clock_gettime( CLOCK_MONOTONIC, &if_time); timeout[packet_id] = if_time.tv_nsec; timestamp[packet_id] /= (30720/spsf); - LOG_D(PHY,"subframe %d: Received packet %d: aid %d, TS %llu, oldTS %llu, diff %lld, \n",subframe,packet_id,aid,(unsigned long long)timestamp[packet_id],(unsigned long long)oldTS,(unsigned long long)(timestamp[packet_id]-timestamp[0])); + LOG_D(PHY,"TTI %d: Received packet %d: aid %d, TS %llu, oldTS %llu, diff %lld, \n",tti,packet_id,aid,(unsigned long long)timestamp[packet_id],(unsigned long long)oldTS,(unsigned long long)(timestamp[packet_id]-timestamp[0])); + if (aid==0) { if (firstTS==1) firstTS=0; else if (oldTS + 256 != timestamp[packet_id]) { @@ -1474,7 +1375,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16 (void*)temp_rx, spp_eth<<2); clock_gettime( CLOCK_MONOTONIC, &end_decomp); - LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp)); + LOG_D(HW,"[TTI %d] IF_Read_Time: %"PRId64"\n",tti,clock_difftime_ns(start_decomp, end_decomp)); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF0, 0 ); } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index f3c8c108dc..eb26dfc02b 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -109,11 +109,11 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, // use OFDM symbol from within 1/8th of the CP to avoid ISI rx_offset -= (nb_prefix_samples / frame_parms->ofdm_offset_divisor); -#ifdef DEBUG_FEP +//#ifdef DEBUG_FEP // if (ue->frame <100) - printf("slot_fep: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, rx_offset %u\n", - Ns, symbol, nb_prefix_samples, nb_prefix_samples0, rx_offset); -#endif + LOG_D(PHY,"slot_fep: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, rx_offset %u energy %d\n", + Ns, symbol, nb_prefix_samples, nb_prefix_samples0, rx_offset, dB_fixed(signal_energy(&common_vars->rxdata[0][rx_offset],frame_parms->ofdm_symbol_size))); + //#endif for (unsigned char aa=0; aanb_antennas_rx; aa++) { memset(&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int32_t)); @@ -129,18 +129,14 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, rxdata_ptr = (int16_t *)tmp_dft_in; } -#if UE_TIMING_TRACE start_meas(&ue->rx_dft_stats); -#endif dft(dftsize, rxdata_ptr, (int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], 1); -#if UE_TIMING_TRACE stop_meas(&ue->rx_dft_stats); -#endif int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol+symb_offset]; @@ -249,18 +245,14 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, } -#if UE_TIMING_TRACE start_meas(&ue->rx_dft_stats); -#endif dft(dftsize, rxdata_ptr, (int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], 1); -#if UE_TIMING_TRACE stop_meas(&ue->rx_dft_stats); -#endif int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol + symb_offset]; @@ -355,23 +347,24 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; + int soffset = (slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; for (int symbol=first_symbol;symbolsymbol_rotation[1])[symbol + symb_offset]; ((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1]; LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,((int16_t*)&rot2)[0],((int16_t*)&rot2)[1]); - rotate_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + rotate_cpx_vector((int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], (int16_t*)&rot2, - (int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + (int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], length, 15); int16_t *shift_rot = frame_parms->timeshift_symbol_rotation; - multadd_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + multadd_cpx_vector((int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], shift_rot, - (int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + (int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], 1, length, 15); diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index 57470cf988..cfb5a2e56e 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -73,8 +73,9 @@ void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) { int min_I0=1000,max_I0=0; int amin=0,amax=0; + fprintf(fd,"Blacklisted PRBs %d/%d\n",gNB->num_ulprbbl,gNB->frame_parms.N_RB_UL); for (int i=0; iframe_parms.N_RB_UL; i++) { - if (i==(gNB->frame_parms.N_RB_UL>>1) - 1) i+=2; + if (gNB->ulprbbl[i] > 0) continue; if (gNB->measurements.n0_subband_power_tot_dB[i]measurements.n0_subband_power_tot_dB[i]; amin=i;} @@ -82,64 +83,88 @@ void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) { } for (int i=0; iframe_parms.N_RB_UL; i++) { - fprintf(fd,"%2d.",gNB->measurements.n0_subband_power_tot_dB[i]-gNB->measurements.n0_subband_power_avg_dB); + if (gNB->ulprbbl[i] ==0) fprintf(fd,"%2d.",gNB->measurements.n0_subband_power_tot_dB[i]-gNB->measurements.n0_subband_power_avg_dB); + else fprintf(fd," X."); if (i%25 == 24) fprintf(fd,"\n"); } - - fprintf(fd,"\nmax_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, gNB->measurements.n0_subband_power_avg_dB); - - fprintf(fd,"PRACH I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); + fprintf(fd,"\n"); + fprintf(fd,"max_IO = %d (%d), min_I0 = %d (%d), avg_I0 = %d dB",max_I0,amax,min_I0,amin,gNB->measurements.n0_subband_power_avg_dB); + if (gNB->frame_parms.nb_antennas_rx>1) { + fprintf(fd,"("); + for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) + fprintf(fd,"%d.",gNB->measurements.n0_subband_power_avg_perANT_dB[aarx]); + fprintf(fd,")"); + } + fprintf(fd,"\nPRACH I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); } -void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb) { +void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_gNB_COMMON *common_vars = &gNB->common_vars; PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements; - uint32_t *rb_mask = gNB->rb_mask_ul; - int rb, offset, offset0, nb_rb, len; + int rb, offset, offset0, nb_symb[275], len; int32_t *ul_ch; - int32_t n0_power_tot; - int64_t n0_power_tot2; - nb_rb = 0; - n0_power_tot2=0; - for (rb=0; rbN_RB_UL; rb++) { - n0_power_tot=0; - offset0 = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; - if ((rb_mask[rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe - nb_rb++; - for (int aarx=0; aarxnb_antennas_rx; aarx++) { - measurements->n0_subband_power[aarx][rb]=0; - for (int s=first_symb;s<(first_symb+num_symb);s++) { + LOG_D(PHY,"slot %d Doing I0 for first_symb %d, num_symb %d\n",slot,first_symb,num_symb); + for (int s=first_symb;s<(first_symb+num_symb);s++) { + for (rb=0; rbN_RB_UL; rb++) { - offset = offset0 + (s*frame_parms->ofdm_symbol_size); - ul_ch = &common_vars->rxdataF[aarx][offset]; - len = 12; - if (((frame_parms->N_RB_UL&1) == 1) && - (rb==(frame_parms->N_RB_UL>>1))) { - len=6; - } - AssertFatal(ul_ch, "RX signal buffer (freq) problem\n"); - measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len); - } // symbol - measurements->n0_subband_power[aarx][rb]/=num_symb; - measurements->n0_subband_power_dB[aarx][rb] = dB_fixed(measurements->n0_subband_power[aarx][rb]); - n0_power_tot += measurements->n0_subband_power[aarx][rb]; - } //antenna - n0_power_tot/=frame_parms->nb_antennas_rx; - n0_power_tot2 += n0_power_tot; - measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_power_tot); + if (s==first_symb) { + nb_symb[rb]=0; + for (int aarx=0; aarxnb_antennas_rx;aarx++) + measurements->n0_subband_power[aarx][rb]=0; + } + offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; + if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe + nb_symb[rb]++; + for (int aarx=0; aarxnb_antennas_rx; aarx++) { + offset = offset0 + (s*frame_parms->ofdm_symbol_size); + ul_ch = &common_vars->rxdataF[aarx][offset]; + len = 12; + if (((frame_parms->N_RB_UL&1) == 1) && + (rb==(frame_parms->N_RB_UL>>1))) { + len=6; + } + AssertFatal(ul_ch, "RX signal buffer (freq) problem\n"); + measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len); + } //antenna + } + } //rb + } // symb + int nb_rb=0; + int32_t n0_subband_tot=0; + int32_t n0_subband_tot_perPRB=0; + int32_t n0_subband_tot_perANT[1+frame_parms->nb_antennas_rx]; + + for (int rb = 0 ; rbN_RB_UL;rb++) { + n0_subband_tot_perPRB=0; + if (nb_symb[rb] > 0) { + for (int aarx=0;aarxnb_antennas_rx;aarx++) { + measurements->n0_subband_power[aarx][rb]/=nb_symb[rb]; + measurements->n0_subband_power_dB[aarx][rb] = dB_fixed(measurements->n0_subband_power[aarx][rb]); + n0_subband_tot_perPRB+=measurements->n0_subband_power[aarx][rb]; + if (rb==0) n0_subband_tot_perANT[aarx]=measurements->n0_subband_power[aarx][rb]; + else n0_subband_tot_perANT[aarx]+=measurements->n0_subband_power[aarx][rb]; + } + n0_subband_tot_perPRB/=frame_parms->nb_antennas_rx; + measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_subband_tot_perPRB); measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - gNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL); + LOG_D(PHY,"n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]); + n0_subband_tot += n0_subband_tot_perPRB; + nb_rb++; } - } //rb - - if (nb_rb>0) measurements->n0_subband_power_avg_dB = dB_fixed(n0_power_tot2/nb_rb); - + } + if (nb_rb>0) { + measurements->n0_subband_power_avg_dB = dB_fixed(n0_subband_tot/nb_rb); + for (int aarx=0;aarxnb_antennas_rx;aarx++) { + measurements->n0_subband_power_avg_perANT_dB[aarx] = dB_fixed(n0_subband_tot_perANT[aarx]/nb_rb); + } + } } @@ -179,6 +204,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq rx_power[ulsch_id][aarx] += meas->rx_spatial_power[ulsch_id][aatx][aarx]; } + LOG_D(PHY, "[ULSCH ID %d] RX power in antenna %d = %d\n", ulsch_id, aarx, rx_power[ulsch_id][aarx]); rx_power_tot[ulsch_id] += rx_power[ulsch_id][aarx]; @@ -190,12 +216,13 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq meas->wideband_cqi_tot[ulsch_id] = dB_fixed2(rx_power_tot[ulsch_id], meas->n0_power_tot); meas->rx_rssi_dBm[ulsch_id] = rx_power_avg_dB[ulsch_id] + 30 - 10 * log10(pow(2, 30)) - (rx_gain - rx_gain_offset) - dB_fixed(fp->ofdm_symbol_size); - LOG_D(PHY, "[ULSCH %d] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d\n", + LOG_D(PHY, "[ULSCH %d] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d, RX Power tot %d\n", ulsch_id, meas->rx_rssi_dBm[ulsch_id], rx_power_avg_dB[ulsch_id], N_RB_UL, meas->wideband_cqi_tot[ulsch_id], - meas->n0_power_tot); + meas->n0_power_tot, + rx_power_tot[ulsch_id]); } diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 960ad82696..1f164748bf 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -68,7 +68,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, uint8_t nushift; int **ul_ch_estimates = gNB->pusch_vars[ul_id]->ul_ch_estimates; int **rxdataF = gNB->common_vars.rxdataF; - + int soffset = (Ns&3)*gNB->frame_parms.symbols_per_slot*gNB->frame_parms.ofdm_symbol_size; nushift = (p>>1)&1; gNB->frame_parms.nushift = nushift; @@ -81,16 +81,14 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, uint16_t nb_rb_pusch = pusch_pdu->rb_size; -#ifdef DEBUG_CH - LOG_I(PHY, "In %s: ch_offset %d, symbol_offset %d OFDM size %d, Ns = %d, k = %d symbol %d\n", + LOG_D(PHY, "In %s: ch_offset %d, soffset %d, symbol_offset %d OFDM size %d, Ns = %d, k = %d symbol %d\n", __FUNCTION__, - ch_offset, + ch_offset, soffset, symbol_offset, gNB->frame_parms.ofdm_symbol_size, Ns, k, symbol); -#endif switch (nushift) { case 0: @@ -174,7 +172,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, re_offset = k; /* Initializing the Resource element offset for each Rx antenna */ pil = (int16_t *)&pilot[0]; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; + rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+k+nushift)]; ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; re_offset = k; @@ -216,7 +214,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, 8); pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; //for (int i= 0; i<8; i++) //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); @@ -247,7 +245,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, 8); pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; //printf("ul_ch addr %p\n",ul_ch); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); @@ -281,8 +279,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - ul_ch += 8; + rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; + ul_ch+=8; for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt += 2) { @@ -299,7 +297,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, 8); pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; //printf("ul_ch addr %p\n",ul_ch); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); @@ -319,9 +317,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - ul_ch += 8; - + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; + ul_ch+=8; } // Treat first 2 pilots specially (right edge) @@ -341,7 +338,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -357,8 +354,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - ul_ch += 8; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; + ul_ch+=8; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -383,7 +380,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch += (idxDC-4); ul_ch = memset(ul_ch, 0, sizeof(int16_t)*10); re_offset = (re_offset+idxDC/2-2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -414,7 +411,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, pil += 4; re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -438,7 +435,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, LOG_D(PHY,"PUSCH estimation DMRS type 2, Freq-domain interpolation"); // Treat first DMRS specially (left edge) - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ul_ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ul_ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -450,7 +447,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, for (re_cnt = 1; re_cnt < (nb_rb_pusch*NR_NB_SC_PER_RB) - 5; re_cnt += 6){ - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -468,7 +465,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, re_offset = (re_offset+5)%gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+symbol_offset+nushift+re_offset]; ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -496,7 +493,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, // Treat last pilot specially (right edge) - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index c8e02fd13d..fd3403236e 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -49,7 +49,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB); -void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb); +void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot,int first_symb,int num_symb); void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq_pid, unsigned char symbol, uint8_t nrOfLayers); diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 11e28a3046..7930839832 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -66,7 +66,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) reset = 1; x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1)); - + LOG_D(PHY,"PDCCH DMRS slot %d, symb %d, Nid %d, x2 %x\n",slot,symb,Nid,x2); for (uint32_t n=0; nsymbols_per_slot; symb++) { reset = 1; x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((N_n_scid[n_scid]<<1)+1) +((N_n_scid[n_scid]<<1)+n_scid)); - LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",slot,symb,x2); + LOG_D(PHY,"PDSCH DMRS slot %d, symb %d x2 %x, N_n_scid %d,n_scid %d\n",slot,symb,x2,N_n_scid[n_scid],n_scid); for (uint32_t n=0; nFreqDomainResource,&n_rb,&rb_offset); @@ -102,7 +103,9 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, // DMRS length is per OFDM symbol uint32_t dmrs_length = n_rb*6; //2(QPSK)*3(per RB)*6(REG per CCE) uint32_t encoded_length = dci_pdu->AggregationLevel*108; //2(QPSK)*9(per RB)*6(REG per CCE) - LOG_D(PHY, "DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d,reg_mapping %d)\n", dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType); + LOG_D(PHY, "DL_DCI : rb_offset %d, nb_rb %d, DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d,reg_mapping %d),Scrambling_Id %d,ScramblingRNTI %x,PayloadSizeBits %d\n", + rb_offset, n_rb,dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType, + dci_pdu->ScramblingId,dci_pdu->ScramblingRNTI,dci_pdu->PayloadSizeBits); dmrs_length += rb_offset*6; // To accommodate more DMRS symbols in case of rb offset /// DMRS QPSK modulation @@ -111,11 +114,11 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated #ifdef DEBUG_PDCCH_DMRS - + if(dci_pdu->RNTI!=0xFFFF) { for (int i=0; i>1; i++) - printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i, - gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); - + printf("symb %d i %d %p gold seq 0x%08x mod_dmrs %d %d\n", symb, i, + &gold_pdcch_dmrs[symb][i>>5],gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); + } #endif } @@ -132,8 +135,8 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, dci_pdu->AggregationLevel, 0,NULL); polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr); -#ifdef DEBUG_CHANNEL_CODING - printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu.AggregationLevel[d]); +#if DEBUG_CHANNEL_CODING + printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,dci_pdu->AggregationLevel); printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n", ((uint64_t*)dci_pdu->Payload)[0], ((uint64_t*)dci_pdu->Payload)[1]); printf("Encoded Payload (length:%d dwords):\n", encoded_length>>5); @@ -211,7 +214,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, (amp * mod_dmrs[l][(dmrs_idx << 1) + 1]) >> 15; #ifdef DEBUG_PDCCH_DMRS - printf("PDCCH DMRS: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms->ofdm_symbol_size + k)<<1], + LOG_D(PHY,"PDCCH DMRS %d: l %d position %d => (%d,%d)\n",dmrs_idx,l,k,((int16_t *)txdataF)[(l*frame_parms->ofdm_symbol_size + k)<<1], ((int16_t *)txdataF)[((l*frame_parms->ofdm_symbol_size + k)<<1)+1]); #endif @@ -223,7 +226,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, ((int16_t *) txdataF)[((l * frame_parms->ofdm_symbol_size + k) << 1) + 1] = (amp * mod_dci[(dci_idx << 1) + 1]) >> 15; #ifdef DEBUG_DCI - printf("PDCCH: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms->ofdm_symbol_size + k)<<1], + LOG_D(PHY,"PDCCH: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms->ofdm_symbol_size + k)<<1], ((int16_t *)txdataF)[((l*frame_parms->ofdm_symbol_size + k)<<1)+1]); #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index e3b53f9cf9..07baaf2728 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -59,6 +59,4 @@ void nr_fill_ul_dci(PHY_VARS_gNB *gNB, void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *); -void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset); - #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index c562dfaa41..1675045443 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -31,6 +31,7 @@ */ #include "nr_dci.h" +#include "common/utils/nr/nr_common.h" //#define DEBUG_FILL_DCI @@ -153,7 +154,7 @@ void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_r C = N_reg/(bsize*R); } - LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", m, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); + if (pdcch_pdu_rel15->dci_pdu[d].RNTI != 0xFFFF) LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", m, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); for (uint8_t cce_idx=0; cce_idxcce_list[d][cce_idx]; cce->cce_idx = pdcch_pdu_rel15->dci_pdu[d].CceIndex + cce_idx; @@ -202,107 +203,3 @@ void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_r ret |= ((field>>i)&1)<<(size-i-1); return ret; }*/ -int16_t find_nr_pdcch(int frame,int slot, PHY_VARS_gNB *gNB,find_type_t type) { - - uint16_t i; - int16_t first_free_index=-1; - - AssertFatal(gNB!=NULL,"gNB is null\n"); - for (i=0; ipdcch_pdu[i].frame,gNB->pdcch_pdu[i].slot,first_free_index); - if ((gNB->pdcch_pdu[i].frame == frame) && - (gNB->pdcch_pdu[i].slot==slot)) return i; - else if ( gNB->pdcch_pdu[i].frame==-1 && first_free_index==-1) first_free_index=i; - } - if (type == SEARCH_EXIST) return -1; - - return first_free_index; -} - - -void nr_fill_dci(PHY_VARS_gNB *gNB, - int frame, - int slot, - nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu) { - - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &pdcch_pdu->pdcch_pdu_rel15; - NR_gNB_DLSCH_t *dlsch; - - int pdcch_id = find_nr_pdcch(frame,slot,gNB,SEARCH_EXIST_OR_FREE); - AssertFatal(pdcch_id>=0 && pdcch_idpdcch_pdu[pdcch_id].pdcch_pdu,(void*)pdcch_pdu,sizeof(*pdcch_pdu)); - gNB->pdcch_pdu[pdcch_id].frame = frame; - gNB->pdcch_pdu[pdcch_id].slot = slot; - - for (int i=0;inumDlDci;i++) { - - //uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->dci_pdu[i].Payload; - - int dlsch_id = find_nr_dlsch(pdcch_pdu_rel15->dci_pdu[i].RNTI,gNB,SEARCH_EXIST_OR_FREE); - if( (dlsch_id<0) || (dlsch_id>=gNB->number_of_nr_dlsch_max) ){ - LOG_E(PHY,"illegal dlsch_id found!!! rnti %04x dlsch_id %d\n",(unsigned int)pdcch_pdu_rel15->dci_pdu[i].RNTI,dlsch_id); - return; - } - - dlsch = gNB->dlsch[dlsch_id][0]; - int harq_pid = 0; - - dlsch->slot_tx[slot] = 1; - dlsch->harq_ids[frame % 2][slot] = 0; - AssertFatal(harq_pid < 8 && harq_pid >= 0, - "illegal harq_pid %d\n",harq_pid); - - dlsch->harq_mask |= (1<rnti = pdcch_pdu_rel15->dci_pdu[i].RNTI; - - // nr_fill_cce_list(gNB,0); - } - -} - - -int16_t find_nr_ul_dci(int frame,int slot, PHY_VARS_gNB *gNB,find_type_t type) { - - uint16_t i; - int16_t first_free_index=-1; - - AssertFatal(gNB!=NULL,"gNB is null\n"); - for (i=0; iul_pdcch_pdu[i].frame,gNB->ul_pdcch_pdu[i].slot,first_free_index); - if ((gNB->ul_pdcch_pdu[i].frame == frame) && - (gNB->ul_pdcch_pdu[i].slot==slot)) return i; - else if (gNB->ul_pdcch_pdu[i].frame==-1 && first_free_index==-1) first_free_index=i; - } - if (type == SEARCH_EXIST) return -1; - - return first_free_index; -} - - -void nr_fill_ul_dci(PHY_VARS_gNB *gNB, - int frame, - int slot, - nfapi_nr_ul_dci_request_pdus_t *pdcch_pdu) { - - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - - int pdcch_id = find_nr_ul_dci(frame,slot,gNB,SEARCH_EXIST_OR_FREE); - AssertFatal(pdcch_id>=0 && pdcch_idul_pdcch_pdu[pdcch_id].pdcch_pdu,(void*)pdcch_pdu,sizeof(*pdcch_pdu)); - gNB->ul_pdcch_pdu[pdcch_id].frame = frame; - gNB->ul_pdcch_pdu[pdcch_id].slot = slot; - - for (int i=0;inumDlDci;i++) { - - //uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->dci_pdu[i].Payload; - - // if there's no DL DCI then generate CCE list - // nr_fill_cce_list(gNB,0); - /* - LOG_D(PHY, "DCI PDU: [0]->0x%lx \t [1]->0x%lx \n",dci_pdu[0], dci_pdu[1]); - LOG_D(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx); - */ - - } - -} diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools_common.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools_common.c deleted file mode 100644 index d26a52f157..0000000000 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools_common.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 - */ - -/*! \file PHY/NR_TRANSPORT/nr_dci_tools_common.c - * \brief - * \author - * \date 2018 - * \version 0.1 - * \company Eurecom - * \email: - * \note - * \warning - */ - -#include "nr_dci.h" - -//#define DEBUG_FILL_DCI - -#include "nr_dlsch.h" - - -void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) { - - uint8_t count=0, start=0, start_set=0; - - uint64_t bitmap = (((uint64_t)FreqDomainResource[0])<<37)| - (((uint64_t)FreqDomainResource[1])<<29)| - (((uint64_t)FreqDomainResource[2])<<21)| - (((uint64_t)FreqDomainResource[3])<<13)| - (((uint64_t)FreqDomainResource[4])<<5)| - (((uint64_t)FreqDomainResource[5])>>3); - - for (int i=0; i<45; i++) - if ((bitmap>>(44-i))&1) { - count++; - if (!start_set) { - start = i; - start_set = 1; - } - } - *rb_offset = 6*start; - *n_rb = 6*count; -} - diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index ce056b5aa5..d75f97aa53 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -37,7 +37,7 @@ #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include "common/utils/nr/nr_common.h" //#define DEBUG_DLSCH //#define DEBUG_DLSCH_MAPPING @@ -111,10 +111,11 @@ void nr_pdsch_codeword_scrambling_optim(uint8_t *in, } -uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, +uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx, int frame, int slot) { + PHY_VARS_gNB *gNB = msgTx->gNB; NR_gNB_DLSCH_t *dlsch; uint32_t ***pdsch_dmrs = gNB->nr_gold_pdsch_dmrs[slot]; int32_t** txdataF = gNB->common_vars.txdataF; @@ -132,9 +133,8 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, time_stats_t *dlsch_interleaving_stats=&gNB->dlsch_interleaving_stats; time_stats_t *dlsch_segmentation_stats=&gNB->dlsch_segmentation_stats; - for (int dlsch_id=0;dlsch_idnumber_of_nr_dlsch_max;dlsch_id++) { - dlsch = gNB->dlsch[dlsch_id][0]; - if (dlsch->slot_tx[slot] == 0) continue; + for (int dlsch_id=0; dlsch_idnum_pdsch_slot; dlsch_id++) { + dlsch = msgTx->dlsch[dlsch_id][0]; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; @@ -527,15 +527,17 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, return 0; } -void dump_pdsch_stats(PHY_VARS_gNB *gNB) { +void dump_pdsch_stats(FILE *fd,PHY_VARS_gNB *gNB) { for (int i=0;idlsch_stats[i].rnti > 0) - LOG_D(PHY,"DLSCH RNTI %x: current_Qm %d, current_RI %d, total_bytes TX %d\n", + if (gNB->dlsch_stats[i].rnti > 0 && gNB->dlsch_stats[i].frame != gNB->dlsch_stats[i].dump_frame) { + gNB->dlsch_stats[i].dump_frame = gNB->dlsch_stats[i].frame; + fprintf(fd,"DLSCH RNTI %x: current_Qm %d, current_RI %d, total_bytes TX %d\n", gNB->dlsch_stats[i].rnti, gNB->dlsch_stats[i].current_Qm, gNB->dlsch_stats[i].current_RI, gNB->dlsch_stats[i].total_bytes_tx); + } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 6af8f28eac..4b6ecfe412 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -63,13 +63,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, uint32_t n_RNTI, uint32_t* out); -void nr_fill_dlsch(PHY_VARS_gNB *gNB, - int frame, - int slot, +void nr_fill_dlsch(processingData_L1tx_t *msgTx, nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, unsigned char *sdu); -uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, +uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx, int frame, int slot); void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB); @@ -98,7 +96,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, void init_dlsch_tpool(uint8_t nun_dlsch_threads); void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size); -void dump_pdsch_stats(PHY_VARS_gNB *gNB); +void dump_pdsch_stats(FILE *fd,PHY_VARS_gNB *gNB); void clear_pdsch_stats(PHY_VARS_gNB *gNB); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 9956e14701..acb59b0e40 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -39,10 +39,10 @@ #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" -#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "SCHED_NR/sched_nr.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/log.h" +#include "common/utils/nr/nr_common.h" #include #include diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c index 543002827d..3ba13d2f44 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c @@ -254,48 +254,16 @@ void nr_emulate_dlsch_payload(uint8_t* pdu, uint16_t size) { *(pdu+i) = (uint8_t)rand(); } -int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) { - - uint16_t i; - int16_t first_free_index=-1; - - AssertFatal(gNB!=NULL,"gNB is null\n"); - for (i=0; inumber_of_nr_dlsch_max; i++) { - AssertFatal(gNB->dlsch[i]!=NULL,"gNB->dlsch[%d] is null\n",i); - AssertFatal(gNB->dlsch[i][0]!=NULL,"gNB->dlsch[%d][0] is null\n",i); - LOG_D(PHY,"searching for rnti %x : dlsch_index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i, - gNB->dlsch[i][0]->harq_mask,gNB->dlsch[i][0]->rnti,first_free_index); - if ((gNB->dlsch[i][0]->harq_mask >0) && - (gNB->dlsch[i][0]->rnti==rnti)) return i; - else if ((gNB->dlsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; - } - if (type == SEARCH_EXIST) return -1; - if (first_free_index != -1) - gNB->dlsch[first_free_index][0]->rnti = 0; - return first_free_index; - -} - - -void nr_fill_dlsch(PHY_VARS_gNB *gNB, - int frame, - int slot, +void nr_fill_dlsch(processingData_L1tx_t *msgTx, nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint8_t *sdu) { - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &pdsch_pdu->pdsch_pdu_rel15; - - int dlsch_id = find_nr_dlsch(rel15->rnti,gNB,SEARCH_EXIST); - AssertFatal( (dlsch_id>=0) && (dlsch_idnumber_of_nr_dlsch_max), - "illegal or no dlsch_id found!!! rnti %04x dlsch_id %d\n",rel15->rnti,dlsch_id); - NR_gNB_DLSCH_t *dlsch = gNB->dlsch[dlsch_id][0]; + NR_gNB_DLSCH_t *dlsch = msgTx->dlsch[msgTx->num_pdsch_slot][0]; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; /// DLSCH struct memcpy((void*)&harq->pdsch_pdu, (void*)pdsch_pdu, sizeof(nfapi_nr_dl_tti_pdsch_pdu)); - gNB->num_pdsch_rnti[slot]++; + msgTx->num_pdsch_slot++; AssertFatal(sdu!=NULL,"sdu is null\n"); harq->pdu = sdu; - - } diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c index a95c519d43..84118e8267 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c @@ -37,7 +37,6 @@ #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "T.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index e535286084..aa51f23cb6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -46,11 +46,11 @@ uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) { AssertFatal(Nl>0,"Nl is 0\n"); AssertFatal(Qm>0,"Qm is 0\n"); - LOG_D(PHY,"nr_get_E : (G %d, C %d, Qm %d, Nl %d, r %d)\n",G, C, Qm, Nl, r); if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1) E = Nl*Qm*(G/(Nl*Qm*Cprime)); else E = Nl*Qm*((G/(Nl*Qm*Cprime))+1); + LOG_D(PHY,"nr_get_E : (G %d, C %d, Qm %d, Nl %d, r %d), E %d\n",G, C, Qm, Nl, r, E); return E; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 54188d22c0..4fed3a468f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -35,7 +35,6 @@ #include "PHY/defs_nr_common.h" #include "PHY/defs_gNB.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" #define NR_PBCH_PDU_BITS 24 @@ -140,6 +139,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, */ void nr_ulsch_extract_rbs_single(int32_t **rxdataF, NR_gNB_PUSCH *pusch_vars, + int slot, unsigned char symbol, uint8_t is_dmrs_symbol, nfapi_nr_pusch_pdu_t *pusch_pdu, @@ -314,6 +314,7 @@ int nr_find_pucch(uint16_t rnti, void init_prach_list(PHY_VARS_gNB *gNB); void init_prach_ru_list(RU_t *ru); void free_nr_ru_prach_entry(RU_t *ru, int prach_id); +uint8_t get_nr_prach_duration(uint8_t prach_format); void nr_generate_csi_rs(PHY_VARS_gNB *gNB, int16_t amp, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 53ff90404b..4278338dbc 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -137,27 +137,24 @@ void nr_ulsch_unscrambling_optim(int16_t* llr, #endif } -#define STATSTRLEN 16384 void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { - char output[16384]; - int stroff=0; - for (int i=0;inumber_of_nr_ulsch_max;i++) { - if (gNB->ulsch_stats[i].rnti>0) { + + if (gNB->ulsch_stats[i].rnti>0 && gNB->ulsch_stats[i].frame != gNB->ulsch_stats[i].dump_frame) { + gNB->ulsch_stats[i].dump_frame = gNB->ulsch_stats[i].frame; for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) - if (aa==0) stroff+=sprintf(output+stroff,"ULSCH RNTI %4x: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d\n", - gNB->ulsch_stats[i].rnti, + if (aa==0) fprintf(fd,"ULSCH RNTI %4x, %d.%d: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d, sync_pos %d\n", + gNB->ulsch_stats[i].rnti,gNB->ulsch_stats[i].frame,gNB->ulsch_stats[i].dump_frame, aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10, - aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10); - else stroff+=sprintf(output+stroff," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n", + aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10, + gNB->ulsch_stats[i].sync_pos); + else fprintf(fd," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n", aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10, aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10); - AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n"); - - stroff+=sprintf(output+stroff," round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, DTX %d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n", + fprintf(fd," round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, DTX %d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n", gNB->ulsch_stats[i].round_trials[0], (double)gNB->ulsch_stats[i].round_trials[1]/gNB->ulsch_stats[i].round_trials[0], gNB->ulsch_stats[i].round_trials[1], @@ -165,14 +162,13 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { gNB->ulsch_stats[i].round_trials[2], (double)gNB->ulsch_stats[i].round_trials[3]/gNB->ulsch_stats[i].round_trials[0], gNB->ulsch_stats[i].round_trials[3], - gNB->ulsch_stats[i].DTX, + gNB->ulsch_stats[i].DTX, gNB->ulsch_stats[i].current_Qm, gNB->ulsch_stats[i].current_RI, gNB->ulsch_stats[i].total_bytes_rx, gNB->ulsch_stats[i].total_bytes_tx); } } - fprintf(fd,"%s",output); } void clear_pusch_stats(PHY_VARS_gNB *gNB) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 7f51c3e488..5286fe8780 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -178,8 +178,6 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ulsch->harq_processes[i]->rar_alloc=0; ulsch->harq_processes[i]->status=NR_SCH_IDLE; ulsch->harq_processes[i]->subframe_scheduling_flag=0; - ulsch->harq_processes[i]->phich_active=0; - ulsch->harq_processes[i]->phich_ACK=0; ulsch->harq_processes[i]->previous_first_rb=0; ulsch->harq_processes[i]->handled=0; ulsch->harq_processes[i]->delta_TF=0; @@ -266,8 +264,8 @@ void nr_processULSegment(void* arg) { int max_ldpc_iterations = p_decoderParms->numMaxIter; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); - int16_t z [68*384]; - int8_t l [68*384]; + int16_t z [68*384 + 16] __attribute__ ((aligned(16))); + int8_t l [68*384 + 16] __attribute__ ((aligned(16))); __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; @@ -328,7 +326,7 @@ void nr_processULSegment(void* arg) { ulsch_harq->e[r], ulsch_harq->C, rv_index, - (ulsch_harq->round==0)?1:0, + ulsch_harq->new_rx, E, ulsch_harq->F, Kr-ulsch_harq->F-2*(p_decoderParms->Z))==-1) { @@ -389,9 +387,10 @@ void nr_processULSegment(void* arg) { if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) { #ifdef PRINT_CRC_CHECK - LOG_I(PHY, "Segment %d CRC OK\n",r); + LOG_I(PHY, "Segment %d CRC OK, iterations %d/%d\n",r,no_iteration_ldpc,max_ldpc_iterations); #endif rdata->decodeIterations = no_iteration_ldpc; + if (rdata->decodeIterations > p_decoderParms->numMaxIter) rdata->decodeIterations--; } else { #ifdef PRINT_CRC_CHECK LOG_I(PHY, "CRC NOK\n"); @@ -466,9 +465,22 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, harq_process->TBS = pusch_pdu->pusch_data.tb_size; harq_process->round = nr_rv_round_map[pusch_pdu->pusch_data.rv_index]; + harq_process->new_rx = false; // flag to indicate if this is a new reception for this harq (initialized to false) + if (harq_process->round == 0) { + harq_process->new_rx = true; + harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; + } + + // this happens if there was a DTX in round 0 + if (harq_process->ndi != pusch_pdu->pusch_data.new_data_indicator) { + harq_process->new_rx = true; + harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; + LOG_E(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index); + } + A = (harq_process->TBS)<<3; - LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers); + LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d, Coderate %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers, R); if (R<1024) Coderate = (float) R /(float) 1024; @@ -514,13 +526,14 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } } if (stats) { + stats->frame = frame; stats->rnti = ulsch->rnti; stats->round_trials[harq_process->round]++; for (int aarx=0;aarxnb_antennas_rx;aarx++) { stats->power[aarx]=dB_fixed_x10(pusch->ulsch_power[aarx]); stats->noise_power[aarx]=dB_fixed_x10(pusch->ulsch_noise_power[aarx]); } - if (harq_process->round == 0) { + if (harq_process->new_rx == 0) { stats->current_Qm = Qm; stats->current_RI = n_layers; stats->total_bytes_tx += harq_process->TBS; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 0531a8b98f..28dd5ab219 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -304,6 +304,7 @@ void nr_idft(int32_t *z, uint32_t Msc_PUSCH) void nr_ulsch_extract_rbs_single(int32_t **rxdataF, NR_gNB_PUSCH *pusch_vars, + int slot, unsigned char symbol, uint8_t is_dmrs_symbol, nfapi_nr_pusch_pdu_t *pusch_pdu, @@ -320,7 +321,7 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF, int16_t *rxF,*rxF_ext; int *ul_ch0,*ul_ch0_ext; uint8_t delta = 0; - + int soffset = (slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; #ifdef DEBUG_RB_EXT printf("--------------------symbol = %d-----------------------\n", symbol); @@ -339,7 +340,7 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF, for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - rxF = (int16_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol * frame_parms->ofdm_symbol_size)]; rxF_ext = (int16_t *)&pusch_vars->rxdataF_ext[aarx][symbol * nb_re_pusch2]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6 ul_ch0 = &pusch_vars->ul_ch_estimates[aarx][pusch_vars->dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available @@ -581,22 +582,29 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, unsigned short nb_rb, unsigned char output_shift) { +#ifdef __AVX2__ + int off = ((nb_rb&1) == 1)? 4:0; +#else + int off = 0; +#endif #ifdef DEBUG_CH_COMP int16_t *rxF, *ul_ch; int prnt_idx; - rxF = (int16_t *)&rxdataF_ext[0][symbol*(off+(nb_rb*12))]; - ul_ch = (int16_t *)&ul_ch_estimates_ext[0][symbol*(off+(nb_rb*1))2]; + for (int ant=0; antnb_antennas_rx; ant++) { + rxF = (int16_t *)&rxdataF_ext[ant][symbol*(off+(nb_rb*12))]; + ul_ch = (int16_t *)&ul_ch_estimates_ext[ant][symbol*(off+(nb_rb*12))]; - printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift); - printf("----------------Before compensation------------------\n"); + printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift); + printf("----------------Before compensation------------------\n"); - for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx+=2){ + for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){ - printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); - printf("ul_ch[%d] = (%d,%d)\n", prnt_idx>>1, ul_ch[prnt_idx],ul_ch[prnt_idx+1]); + printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); + printf("ul_ch[%d] = (%d,%d)\n", prnt_idx>>1, ul_ch[prnt_idx],ul_ch[prnt_idx+1]); + } } #endif @@ -606,25 +614,21 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, int print_idx; - ch_mag = (int16_t *)&ul_ch_mag[0][symbol*(off+(nb_rb*12))]; + for (int ant=0; antnb_antennas_rx; ant++) { + ch_mag = (int16_t *)&ul_ch_mag[ant][symbol*(off+(nb_rb*12))]; - printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order); - printf("----------------Before computation------------------\n"); + printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order); + printf("----------------Before computation------------------\n"); - for (print_idx=0;print_idx<50;print_idx++){ + for (print_idx=0;print_idx<5;print_idx++){ - printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]); + printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]); + } } #endif -#ifdef __AVX2__ - int off = ((nb_rb&1) == 1)? 4:0; -#else - int off = 0; -#endif - #if defined(__i386) || defined(__x86_64__) unsigned short rb; @@ -1067,14 +1071,16 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, #ifdef DEBUG_CH_COMP - rxF = (int16_t *)&rxdataF_comp[0][(symbol*(off+(nb_rb*12)))]; + for (int ant=0; antnb_antennas_rx; ant++) { + rxF = (int16_t *)&rxdataF_comp[ant][(symbol*(off+(nb_rb*12)))]; - printf("----------------After compansation------------------\n"); + printf("----------------After compansation------------------\n"); - for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx+=2){ + for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){ - printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); + printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); + } } #endif @@ -1082,14 +1088,16 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, #ifdef DEBUG_CH_MAG - ch_mag = (int16_t *)&ul_ch_mag[0][(symbol*(off+(nb_rb*12)))]; + for (int ant=0; antnb_antennas_rx; ant++) { + ch_mag = (int16_t *)&ul_ch_mag[ant][(symbol*(off+(nb_rb*12)))]; - printf("----------------After computation------------------\n"); + printf("----------------After computation------------------\n"); - for (print_idx=0;print_idx<12*nb_rb*2;print_idx+=2){ + for (print_idx=0;print_idx<12*5*2;print_idx+=2){ - printf("ch_mag[%d] = (%d,%d)\n", print_idx>>1, ch_mag[print_idx],ch_mag[print_idx+1]); + printf("ch_mag[%d] = (%d,%d)\n", print_idx>>1, ch_mag[print_idx],ch_mag[print_idx+1]); + } } #endif @@ -1124,13 +1132,13 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, rxdataF_comp128[aa] = (__m128i *)&rxdataF_comp[aa][(symbol*(nb_re + off))]; ul_ch_mag128[aa] = (__m128i *)&ul_ch_mag[aa][(symbol*(nb_re + off))]; ul_ch_mag128b[aa] = (__m128i *)&ul_ch_magb[aa][(symbol*(nb_re + off))]; - + } + for (int aa=1;aanb_antennas_rx;aa++) { // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) for (i=0; ipusch_vars[ulsch_id]->cl_done = 0; bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; - LOG_D(PHY,"bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); - LOG_D(PHY,"ul_dmrs_symb_pos %x\n",rel15_ul->ul_dmrs_symb_pos); + LOG_D(PHY,"pusch %d.%d : bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", frame,slot,bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); + LOG_D(PHY,"pusch %d.%d : ul_dmrs_symb_pos %x\n",frame,slot,rel15_ul->ul_dmrs_symb_pos); //---------------------------------------------------------- //--------------------- Channel estimation --------------------- @@ -1257,6 +1265,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, start_meas(&gNB->ulsch_rbs_extraction_stats); nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, gNB->pusch_vars[ulsch_id], + slot, symbol, dmrs_symbol_flag, rel15_ul, @@ -1289,7 +1298,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, for (aarx=0;aarxnb_antennas_rx;aarx++) avgs = cmax(avgs,avg[aatx*frame_parms->nb_antennas_rx+aarx]); - gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+3; + gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+2; gNB->pusch_vars[ulsch_id]->cl_done = 1; } @@ -1297,6 +1306,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, //--------------------- Channel Compensation --------------- //---------------------------------------------------------- start_meas(&gNB->ulsch_channel_compensation_stats); + LOG_D(PHY,"Doing channel compensations log2_maxh %d, avgs %d (%d,%d)\n",gNB->pusch_vars[ulsch_id]->log2_maxh,avgs,avg[0],avg[1]); nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext, gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, gNB->pusch_vars[ulsch_id]->ul_ch_mag0, @@ -1315,8 +1325,8 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, start_meas(&gNB->ulsch_mrc_stats); nr_ulsch_detection_mrc(frame_parms, gNB->pusch_vars[ulsch_id]->rxdataF_comp, - gNB->pusch_vars[ulsch_id]->ul_ch_mag, - gNB->pusch_vars[ulsch_id]->ul_ch_magb, + gNB->pusch_vars[ulsch_id]->ul_ch_mag0, + gNB->pusch_vars[ulsch_id]->ul_ch_magb0, symbol, rel15_ul->rb_size); stop_meas(&gNB->ulsch_mrc_stats); diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index e3b87ff233..cdc6825d4c 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -170,7 +170,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int32_t **rxdataF = gNB->common_vars.rxdataF; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - + int soffset=(slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; int nr_sequences; const uint8_t *mcs; @@ -206,7 +206,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, nr_sequences=8>>(1-pucch_pdu->sr_flag); } - LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,mcs[0]); + LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d initial_cyclic_shift %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,mcs[0],pucch_pdu->initial_cyclic_shift); int cs_ind = get_pucch0_cs_lut_index(gNB,pucch_pdu); /* @@ -238,7 +238,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, // x_n contains the sequence r_u_v_alpha_delta(n) - int n,i,l; + int n,i; int prb_offset[2] = {pucch_pdu->bwp_start+pucch_pdu->prb_start, pucch_pdu->bwp_start+pucch_pdu->prb_start}; nr_group_sequence_hopping(pucch_GroupHopping,pucch_pdu->hopping_id,0,slot,&u[0],&v[0]); // calculating u and v value first hop @@ -251,6 +251,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, prb_offset[1] = pucch_pdu->bwp_start+pucch_pdu->second_hop_prb; } + AssertFatal(pucch_pdu->nr_of_symbols < 3,"nr_of_symbols %d not allowed\n",pucch_pdu->nr_of_symbols); uint32_t re_offset[2]={0,0}; uint8_t l2; @@ -261,106 +262,143 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, x_re[1] = table_5_2_2_2_2_Re[u[1]]; x_im[1] = table_5_2_2_2_2_Im[u[1]]; - int16_t xr[2][24] __attribute__((aligned(32))); - int64_t xrtmag=0; + int16_t xr[1+frame_parms->nb_antennas_rx][1+pucch_pdu->nr_of_symbols][24] __attribute__((aligned(32))); + int64_t xrtmag=0,xrtmag_next=0; uint8_t maxpos=0; uint8_t index=0; - memset((void*)xr[0],0,24*sizeof(int16_t)); - memset((void*)xr[1],0,24*sizeof(int16_t)); + for (int l=0; lnr_of_symbols; l++) { + for (int aarx=0;aarxnb_antennas_rx;aarx++) { + memset((void*)xr[aarx][l],0,24*sizeof(int16_t)); + } + } int n2; - for (l=0; lnr_of_symbols; l++) { + for (int l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; re_offset[l] = (12*prb_offset[l]) + frame_parms->first_carrier_offset; if (re_offset[l]>= frame_parms->ofdm_symbol_size) re_offset[l]-=frame_parms->ofdm_symbol_size; AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); - - int16_t *r=(int16_t*)&rxdataF[0][(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; - n2=0; - for (n=0;n<12;n++,n2+=2) { - xr[l][n2] =(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15); - xr[l][n2+1]=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); + int16_t *r; + for (int aa=0;aanb_antennas_rx;aa++) { + r=(int16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; + n2=0; + for (n=0;n<12;n++,n2+=2) { + xr[aa][l][n2] +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15); + xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); #ifdef DEBUG_NR_PUCCH_RX - printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n", - x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[l][n2],xr[l][n2+1]); + printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n", + x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]); #endif + } } } - int32_t corr_re[2]; - int32_t corr_im[2]; - + int32_t corr_re[1+frame_parms->nb_antennas_rx][2]; + int32_t corr_im[1+frame_parms->nb_antennas_rx][2]; + //int32_t no_corr = 0; int seq_index; int64_t temp; - int64_t av_corr=0; for(i=0;inr_of_symbols;l++) { - corr_re[l]=0; - corr_im[l]=0; + + for (int l=0;lnr_of_symbols;l++) { seq_index = (pucch_pdu->initial_cyclic_shift+ mcs[i]+ gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12; #ifdef DEBUG_NR_PUCCH_RX printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]); #endif - n2=0; - for (n=0;n<12;n++,n2+=2) { - corr_re[l]+=(xr[l][n2]*idft12_re[seq_index][n]+xr[l][n2+1]*idft12_im[seq_index][n])>>15; - corr_im[l]+=(xr[l][n2]*idft12_im[seq_index][n]-xr[l][n2+1]*idft12_re[seq_index][n])>>15; + for (int aa=0;aanb_antennas_rx;aa++) { + corr_re[aa][l]=0; + corr_im[aa][l]=0; + + n2=0; + for (n=0;n<12;n++,n2+=2) { + corr_re[aa][l]+=(xr[aa][l][n2]*idft12_re[seq_index][n]+xr[aa][l][n2+1]*idft12_im[seq_index][n])>>15; + corr_im[aa][l]+=(xr[aa][l][n2]*idft12_im[seq_index][n]-xr[aa][l][n2+1]*idft12_re[seq_index][n])>>15; + } } } - -#ifdef DEBUG_NR_PUCCH_RX - LOG_I(PHY,"PUCCH IDFT = (%d,%d)=>%f\n",corr_re[0],corr_im[0],10*log10((double)corr_re[0]*corr_re[0] + (double)corr_im[0]*corr_im[0])); - if (l>1) LOG_I(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n",mcs[i],seq_index,corr_re[1],corr_im[1],10*log10((double)corr_re[1]*corr_re[1] + (double)corr_im[1]*corr_im[1])); -#endif - if (pucch_pdu->freq_hop_flag == 0 && l==1) // non-coherent correlation - temp=(int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0]; - else if (pucch_pdu->freq_hop_flag == 0 && l==2) { - int64_t corr_re2 = (int64_t)corr_re[0]+corr_re[1]; - int64_t corr_im2 = (int64_t)corr_im[0]+corr_im[1]; - // coherent combining of 2 symbols and then complex modulus for single-frequency case - temp=corr_re2*corr_re2 + corr_im2*corr_im2; - } - else if (pucch_pdu->freq_hop_flag == 1) + LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n", + mcs[i],seq_index,corr_re[0][0],corr_im[0][0], + 10*log10((double)corr_re[0][0]*corr_re[0][0] + (double)corr_im[0][0]*corr_im[0][0])); + if (pucch_pdu->nr_of_symbols==2) + LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n", + mcs[i],seq_index,corr_re[0][1],corr_im[0][1], + 10*log10((double)corr_re[0][1]*corr_re[0][1] + (double)corr_im[0][1]*corr_im[0][1])); + if (pucch_pdu->freq_hop_flag == 0) { + if (pucch_pdu->nr_of_symbols==1) {// non-coherent correlation + temp=0; + for (int aa=0;aanb_antennas_rx;aa++) + temp+=(int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]; + } else { + int64_t corr_re2=0; + int64_t corr_im2=0; + temp=0; + for (int aa=0;aanb_antennas_rx;aa++) { + corr_re2 = (int64_t)corr_re[aa][0]+corr_re[aa][1]; + corr_im2 = (int64_t)corr_im[aa][0]+corr_im[aa][1]; + // coherent combining of 2 symbols and then complex modulus for single-frequency case + temp+=corr_re2*corr_re2 + corr_im2*corr_im2; + } + } + } else if (pucch_pdu->freq_hop_flag == 1) { // full non-coherent combining of 2 symbols for frequency-hopping case - temp = (int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0] + (int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1]; + temp=0; + for (int aa=0;aanb_antennas_rx;aa++) + temp += (int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0] + (int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]; + } else AssertFatal(1==0,"shouldn't happen\n"); - av_corr+=temp; if (temp>xrtmag) { + xrtmag_next = xrtmag; xrtmag=temp; + LOG_D(PHY,"Sequence %d xrtmag %ld xrtmag_next %ld\n", i, xrtmag, xrtmag_next); maxpos=i; - uci_stats->current_pucch0_stat0 = dB_fixed64((int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0]); - if (l==2) uci_stats->current_pucch0_stat1 = dB_fixed64((int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1]); + uci_stats->current_pucch0_stat0 = 0; + int64_t temp2=0,temp3=0;; + for (int aa=0;aanb_antennas_rx;aa++) { + temp2 += ((int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]); + if (pucch_pdu->nr_of_symbols==2) + temp3 += ((int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]); + } + uci_stats->current_pucch0_stat0= dB_fixed64(temp2); + if ( pucch_pdu->nr_of_symbols==2) + uci_stats->current_pucch0_stat1= dB_fixed64(temp3); } + else if (temp>xrtmag_next) + xrtmag_next = temp; } - av_corr/=nr_sequences/l; - - uint8_t xrtmag_dB = dB_fixed64(xrtmag); - + int xrtmag_dBtimes10 = 10*(int)dB_fixed64(xrtmag/(12*pucch_pdu->nr_of_symbols)); + int xrtmag_next_dBtimes10 = 10*(int)dB_fixed64(xrtmag_next/(12*pucch_pdu->nr_of_symbols)); #ifdef DEBUG_NR_PUCCH_RX printf("PUCCH 0 : maxpos %d\n",maxpos); #endif index=maxpos; - + uci_stats->pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]]; + uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; + LOG_D(PHY,"n00[%d] = %d, n01[%d] = %d\n",prb_offset[0],uci_stats->pucch0_n00,prb_offset[1],uci_stats->pucch0_n01); // estimate CQI for MAC (from antenna port 0 only) int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01; - int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12)) - (10*max_n0); + int SNRtimes10,sigenergy=0; + for (int aa=0;aanb_antennas_rx;aa++) + sigenergy += signal_energy_nodc(&rxdataF[aa][soffset+ + (pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size)+ + re_offset[0]],12); + SNRtimes10 = xrtmag_dBtimes10-(10*max_n0); int cqi; if (SNRtimes10 < -640) cqi=0; else if (SNRtimes10 > 635) cqi=255; else cqi=(640+SNRtimes10)/5; - uci_stats->pucch0_thres = gNB->pucch0_thres + (10*max_n0); + uci_stats->pucch0_thres = gNB->pucch0_thres; /* + (10*max_n0);*/ bool no_conf=false; if (nr_sequences>1) { - if (10*xrtmag_dB < uci_stats->pucch0_thres) + if (xrtmag_dBtimes10 < (50+xrtmag_next_dBtimes10) || SNRtimes10 < uci_stats->pucch0_thres) no_conf=true; } gNB->bad_pucch += no_conf; @@ -370,16 +408,14 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->rnti = pucch_pdu->rnti; uci_pdu->ul_cqi = cqi; uci_pdu->timing_advance = 0xffff; // currently not valid - uci_pdu->rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12))); + uci_pdu->rssi = 1280 - (10*dB_fixed(32767*32767))-dB_fixed_times10(sigenergy); - uci_stats->pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]]; - uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; if (pucch_pdu->bit_len_harq==0) { uci_pdu->harq = NULL; uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0; uci_stats->pucch0_sr_trials++; - if (xrtmag_dB>(gNB->measurements.n0_power_tot_dB)) { + if (xrtmag_dBtimes10>(10*gNB->measurements.n0_power_tot_dB)) { uci_pdu->sr->sr_indication = 1; uci_stats->pucch0_positive_SR++; } else { @@ -392,8 +428,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_confidence_level = no_conf ? 1 : 0; uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); uci_pdu->harq->harq_list[0].harq_value = index&0x01; - LOG_D(PHY, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d n0 %d pucch0_thres %d\n", - slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB,max_n0,uci_stats->pucch0_thres); + LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n", + frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_indication = (index>1) ? 1 : 0; @@ -409,8 +445,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); uci_pdu->harq->harq_list[1].harq_value = index&0x01; uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01; - LOG_D(PHY, "Slot %d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d\n", - slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB); + LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n", + frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,gNB->ulsch_stats[0].sync_pos); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_indication = (index>3) ? 1 : 0; @@ -445,6 +481,7 @@ void nr_decode_pucch1( int32_t **rxdataF, * Implement TS 38.211 Subclause 6.3.2.4.1 Sequence modulation * */ + int soffset = (nr_tti_tx&3)*frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size; // complex-valued symbol d_re, d_im containing complex-valued symbol d(0): int16_t d_re=0, d_im=0,d1_re=0,d1_im=0; #ifdef DEBUG_NR_PUCCH_RX @@ -539,23 +576,23 @@ void nr_decode_pucch1( int32_t **rxdataF, } if (l%2 == 1) { // mapping PUCCH according to TS38.211 subclause 6.4.1.3.1 - z_re_rx[i+n] = ((int16_t *)&rxdataF[0][re_offset])[0]; - z_im_rx[i+n] = ((int16_t *)&rxdataF[0][re_offset])[1]; + z_re_rx[i+n] = ((int16_t *)&rxdataF[0][soffset+re_offset])[0]; + z_im_rx[i+n] = ((int16_t *)&rxdataF[0][soffset+re_offset])[1]; #ifdef DEBUG_NR_PUCCH_RX printf("\t [nr_generate_pucch1] mapping PUCCH to RE \t amp=%d \tofdm_symbol_size=%d \tN_RB_DL=%d \tfirst_carrier_offset=%d \tz_pucch[%d]=txptr(%u)=(x_n(l=%d,n=%d)=(%d,%d))\n", amp,frame_parms->ofdm_symbol_size,frame_parms->N_RB_DL,frame_parms->first_carrier_offset,i+n,re_offset, - l,n,((int16_t *)&rxdataF[0][re_offset])[0],((int16_t *)&rxdataF[0][re_offset])[1]); + l,n,((int16_t *)&rxdataF[0][soffset+re_offset])[0],((int16_t *)&rxdataF[0][soffset+re_offset])[1]); #endif } if (l%2 == 0) { // mapping DM-RS signal according to TS38.211 subclause 6.4.1.3.1 - z_dmrs_re_rx[i+n] = ((int16_t *)&rxdataF[0][re_offset])[0]; - z_dmrs_im_rx[i+n] = ((int16_t *)&rxdataF[0][re_offset])[1]; + z_dmrs_re_rx[i+n] = ((int16_t *)&rxdataF[0][soffset+re_offset])[0]; + z_dmrs_im_rx[i+n] = ((int16_t *)&rxdataF[0][soffset+re_offset])[1]; // printf("%d\t%d\t%d\n",l,z_dmrs_re_rx[i+n],z_dmrs_im_rx[i+n]); #ifdef DEBUG_NR_PUCCH_RX printf("\t [nr_generate_pucch1] mapping DM-RS to RE \t amp=%d \tofdm_symbol_size=%d \tN_RB_DL=%d \tfirst_carrier_offset=%d \tz_dm-rs[%d]=txptr(%u)=(x_n(l=%d,n=%d)=(%d,%d))\n", amp,frame_parms->ofdm_symbol_size,frame_parms->N_RB_DL,frame_parms->first_carrier_offset,i+n,re_offset, - l,n,((int16_t *)&rxdataF[0][re_offset])[0],((int16_t *)&rxdataF[0][re_offset])[1]); + l,n,((int16_t *)&rxdataF[0][soffset+re_offset])[0],((int16_t *)&rxdataF[0][soffset+re_offset])[1]); #endif // printf("l=%d\ti=%d\tre_offset=%d\treceived dmrs re=%d\tim=%d\n",l,i,re_offset,z_dmrs_re_rx[i+n],z_dmrs_im_rx[i+n]); } @@ -1081,85 +1118,109 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, //extract pucch and dmrs first int l2=pucch_pdu->start_symbol_index; - int re_offset = (12*pucch_pdu->prb_start) + (12*pucch_pdu->bwp_start) + frame_parms->first_carrier_offset; - if (re_offset>= frame_parms->ofdm_symbol_size) - re_offset-=frame_parms->ofdm_symbol_size; - + int re_offset[2]; + re_offset[0] = 12*(pucch_pdu->prb_start+pucch_pdu->bwp_start) + frame_parms->first_carrier_offset; + int soffset=(slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; + + if (re_offset[0]>= frame_parms->ofdm_symbol_size) + re_offset[0]-=frame_parms->ofdm_symbol_size; + if (pucch_pdu->freq_hop_flag == 0) re_offset[1] = re_offset[0]; + else { + re_offset[1] = 12*(pucch_pdu->second_hop_prb+pucch_pdu->bwp_start) + frame_parms->first_carrier_offset; + if (re_offset[1]>= frame_parms->ofdm_symbol_size) + re_offset[1]-=frame_parms->ofdm_symbol_size; + } AssertFatal(pucch_pdu->prb_size*pucch_pdu->nr_of_symbols > 1,"number of PRB*SYMB (%d,%d)< 2", pucch_pdu->prb_size,pucch_pdu->nr_of_symbols); int Prx = gNB->gNB_config.carrier_config.num_rx_ant.value; int Prx2 = (Prx==1)?2:Prx; // use 2 for Nb antennas in case of single antenna to allow the following allocations - int16_t r_re_ext[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); - int16_t r_im_ext[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); - int16_t r_re_ext2[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); - int16_t r_im_ext2[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); - int16_t rd_re_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); - int16_t rd_im_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); + int prb_size_ext = pucch_pdu->prb_size+(pucch_pdu->prb_size&1); + int16_t r_re_ext[Prx2][2][8*prb_size_ext] __attribute__((aligned(32))); + int16_t r_im_ext[Prx2][2][8*prb_size_ext] __attribute__((aligned(32))); + int16_t r_re_ext2[Prx2][2][8*prb_size_ext] __attribute__((aligned(32))); + int16_t r_im_ext2[Prx2][2][8*prb_size_ext] __attribute__((aligned(32))); + int16_t rd_re_ext[Prx2][2][4*prb_size_ext] __attribute__((aligned(32))); + int16_t rd_im_ext[Prx2][2][4*prb_size_ext] __attribute__((aligned(32))); int16_t *r_re_ext_p,*r_im_ext_p,*rd_re_ext_p,*rd_im_ext_p; int nb_re_pucch = 12*pucch_pdu->prb_size; - int16_t rp[Prx2][nb_re_pucch*2],*tmp_rp; + int16_t rp[Prx2][2][nb_re_pucch*2],*tmp_rp; __m64 dmrs_re,dmrs_im; for (int aa=0;aaofdm_symbol_size]); + for (int symb=0;symbnr_of_symbols;symb++) { + tmp_rp = ((int16_t *)&rxdataF[aa][soffset + (l2+symb)*frame_parms->ofdm_symbol_size]); - if (re_offset + nb_re_pucch < frame_parms->ofdm_symbol_size) { - memcpy1((void*)rp[aa],(void*)&tmp_rp[re_offset*2],nb_re_pucch*sizeof(int32_t)); - } - else { - int neg_length = frame_parms->ofdm_symbol_size-re_offset; - int pos_length = nb_re_pucch-neg_length; - memcpy1((void*)rp[aa],(void*)&tmp_rp[re_offset*2],neg_length*sizeof(int32_t)); - memcpy1((void*)&rp[aa][neg_length*2],(void*)tmp_rp,pos_length*sizeof(int32_t)); + if (re_offset[symb] + nb_re_pucch < frame_parms->ofdm_symbol_size) { + memcpy1((void*)rp[aa][symb],(void*)&tmp_rp[re_offset[symb]*2],nb_re_pucch*sizeof(int32_t)); + } + else { + int neg_length = frame_parms->ofdm_symbol_size-re_offset[symb]; + int pos_length = nb_re_pucch-neg_length; + memcpy1((void*)rp[aa][symb],(void*)&tmp_rp[re_offset[symb]*2],neg_length*sizeof(int32_t)); + memcpy1((void*)&rp[aa][symb][neg_length*2],(void*)tmp_rp,pos_length*sizeof(int32_t)); + } } } - #ifdef DEBUG_NR_PUCCH_RX printf("Decoding pucch2 for %d symbols, %d PRB\n",pucch_pdu->nr_of_symbols,pucch_pdu->prb_size); #endif int nc_group_size=1; // 2 PRB - int ngroup = pucch_pdu->prb_size/nc_group_size/2; - int32_t corr32_re[ngroup][Prx2],corr32_im[ngroup][Prx2]; - for (int aa=0;aanr_of_symbols == 1) { - AssertFatal((pucch_pdu->prb_size&1) == 0,"prb_size %d is not a multiple of 2\n",pucch_pdu->prb_size); - // 24 PRBs contains 48x16-bit, so 6x8x16-bit + // AssertFatal((pucch_pdu->prb_size&1) == 0,"prb_size %d is not a multiple of 2\n",pucch_pdu->prb_size); + if ((pucch_pdu->prb_size&1) > 0) { // if the number of PRBs is odd + for (int symb=0; symbnr_of_symbols;symb++) { + for (int aa=0;aaprb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t)); + memset(&r_im_ext[aa][symb][8*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t)); + memset(&rd_re_ext[aa][symb][4*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t)); + memset(&rd_im_ext[aa][symb][4*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t)); + } + } + } + for (int symb=0; symbnr_of_symbols;symb++) { + // 24 REs contains 48x16-bit, so 6x8x16-bit for (int prb=0;prbprb_size;prb+=2) { for (int aa=0;aa (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext_p[i],rd_im_ext_p[i]); - for (int i=0;i<16;i++) printf("Ant %d PRB %d data[%d] -> (%d,%d)\n",aa,prb+(i>>3),i,r_re_ext_p[i],r_im_ext_p[i]); + for (int i=0;i<8;i++) printf("Ant %d PRB %d dmrs[%d] -> (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext_p[i],rd_im_ext_p[i]); + for (int i=0;i<16;i++) printf("Ant %d PRB %d data[%d] -> (%d,%d)\n",aa,prb+(i>>3),i,r_re_ext_p[i],r_im_ext_p[i]); #endif } // aa } // prb - // first compute DMRS component + uint32_t x1, x2, s=0; - x2 = (((1<<17)*((14*slot) + (pucch_pdu->start_symbol_index) + 1)*((2*pucch_pdu->dmrs_scrambling_id) + 1)) + (2*pucch_pdu->dmrs_scrambling_id))%(1U<<31); // c_init calculation according to TS38.211 subclause + x2 = (((1<<17)*((14*slot) + (pucch_pdu->start_symbol_index+symb) + 1)*((2*pucch_pdu->dmrs_scrambling_id) + 1)) + (2*pucch_pdu->dmrs_scrambling_id))%(1U<<31); // c_init calculation according to TS38.211 subclause #ifdef DEBUG_NR_PUCCH_RX - printf("slot %d, start_symbol_index %d, dmrs_scrambling_id %d\n", - slot,pucch_pdu->start_symbol_index,pucch_pdu->dmrs_scrambling_id); + printf("slot %d, start_symbol_index %d, symbol %d, dmrs_scrambling_id %d\n", + slot,pucch_pdu->start_symbol_index,symb,pucch_pdu->dmrs_scrambling_id); #endif int reset = 1; for (int i=0; i<=(pucch_pdu->prb_start>>2); i++) { @@ -1174,77 +1235,74 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, dmrs_im = byte2m64_im[((uint8_t*)&s)[(group&1)<<1]]; #ifdef DEBUG_NR_PUCCH_RX printf("Group %d: s %x x2 %x ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n", - group, - ((uint16_t*)&s)[0],x2, - ((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0], - ((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1], - ((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2], - ((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]); + group, + ((uint16_t*)&s)[0],x2, + ((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0], + ((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1], + ((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2], + ((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]); #endif for (int aa=0;aa>=5; - corr32_im[group][aa]>>=5; + corr32_re[symb][group][aa]+=(rd_re_ext_p[4]*((int16_t*)&dmrs_re)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_im)[0]); + corr32_im[symb][group][aa]+=(-rd_re_ext_p[4]*((int16_t*)&dmrs_im)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_re)[0]); + corr32_re[symb][group][aa]+=(rd_re_ext_p[5]*((int16_t*)&dmrs_re)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_im)[1]); + corr32_im[symb][group][aa]+=(-rd_re_ext_p[5]*((int16_t*)&dmrs_im)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_re)[1]); + corr32_re[symb][group][aa]+=(rd_re_ext_p[6]*((int16_t*)&dmrs_re)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_im)[2]); + corr32_im[symb][group][aa]+=(-rd_re_ext_p[6]*((int16_t*)&dmrs_im)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_re)[2]); + corr32_re[symb][group][aa]+=(rd_re_ext_p[7]*((int16_t*)&dmrs_re)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_im)[3]); + corr32_im[symb][group][aa]+=(-rd_re_ext_p[7]*((int16_t*)&dmrs_im)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_re)[3]); + /* corr32_re[group][aa]>>=5; + corr32_im[group][aa]>>=5;*/ #ifdef DEBUG_NR_PUCCH_RX - printf("Group %d: corr32 (%d,%d)\n",group,corr32_re[group][aa],corr32_im[group][aa]); + printf("Group %d: corr32 (%d,%d)\n",group,corr32_re[symb][group][aa],corr32_im[symb][group][aa]); #endif } //aa - + if ((group&1) == 1) s = lte_gold_generic(&x1, &x2, 0); } // group - } - else { // 2 symbol case - AssertFatal(1==0, "Fill in 2 symbol PUCCH2 case\n"); - } + } // symb uint32_t x1, x2, s=0; // unscrambling @@ -1253,112 +1311,114 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #ifdef DEBUG_NR_PUCCH_RX printf("x2 %x, s %x\n",x2,s); #endif - __m64 c_re0,c_im0,c_re1,c_im1,c_re2,c_im2,c_re3,c_im3; - re_offset=0; - for (int prb=0;prbprb_size;prb+=2,re_offset+=16) { - c_re0 = byte2m64_re[((uint8_t*)&s)[0]]; - c_im0 = byte2m64_im[((uint8_t*)&s)[0]]; - c_re1 = byte2m64_re[((uint8_t*)&s)[1]]; - c_im1 = byte2m64_im[((uint8_t*)&s)[1]]; - c_re2 = byte2m64_re[((uint8_t*)&s)[2]]; - c_im2 = byte2m64_im[((uint8_t*)&s)[2]]; - c_re3 = byte2m64_re[((uint8_t*)&s)[3]]; - c_im3 = byte2m64_im[((uint8_t*)&s)[3]]; + for (int symb=0;symbnr_of_symbols;symb++) { + __m64 c_re0,c_im0,c_re1,c_im1,c_re2,c_im2,c_re3,c_im3; + int re_off=0; + for (int prb=0;prbbit_len_harq+pucch_pdu->sr_flag+pucch_pdu->bit_len_csi_part1+pucch_pdu->bit_len_csi_part2; AssertFatal(nb_bit > 2 && nb_bit< 65,"illegal length (%d : %d,%d,%d,%d)\n",nb_bit,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,pucch_pdu->bit_len_csi_part1,pucch_pdu->bit_len_csi_part2); @@ -1366,15 +1426,17 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uint8_t corr_dB; int decoderState=2; if (nb_bit < 12) { // short blocklength case - __m256i *rp_re[Prx2]; - __m256i *rp2_re[Prx2]; - __m256i *rp_im[Prx2]; - __m256i *rp2_im[Prx2]; + __m256i *rp_re[Prx2][2]; + __m256i *rp2_re[Prx2][2]; + __m256i *rp_im[Prx2][2]; + __m256i *rp2_im[Prx2][2]; for (int aa=0;aanr_of_symbols;symb++) { + rp_re[aa][symb] = (__m256i*)r_re_ext[aa][symb]; + rp_im[aa][symb] = (__m256i*)r_im_ext[aa][symb]; + rp2_re[aa][symb] = (__m256i*)r_re_ext2[aa][symb]; + rp2_im[aa][symb] = (__m256i*)r_im_ext2[aa][symb]; + } } __m256i prod_re[Prx2],prod_im[Prx2]; uint64_t corr=0; @@ -1393,76 +1455,91 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #endif uint64_t corr_tmp = 0; - for (int group=0;groupnr_of_symbols;symb++) { + for (int group=0;group (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",aa, - ((int16_t*)&prod_re[aa])[0],((int16_t*)&prod_re[aa])[1],((int16_t*)&prod_re[aa])[2],((int16_t*)&prod_re[aa])[3], - ((int16_t*)&prod_re[aa])[4],((int16_t*)&prod_re[aa])[5],((int16_t*)&prod_re[aa])[6],((int16_t*)&prod_re[aa])[7], - ((int16_t*)&prod_re[aa])[8],((int16_t*)&prod_re[aa])[9],((int16_t*)&prod_re[aa])[10],((int16_t*)&prod_re[aa])[11], - ((int16_t*)&prod_re[aa])[12],((int16_t*)&prod_re[aa])[13],((int16_t*)&prod_re[aa])[14],((int16_t*)&prod_re[aa])[15]); - printf("prod_im[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",aa, - ((int16_t*)&prod_im[aa])[0],((int16_t*)&prod_im[aa])[1],((int16_t*)&prod_im[aa])[2],((int16_t*)&prod_im[aa])[3], - ((int16_t*)&prod_im[aa])[4],((int16_t*)&prod_im[aa])[5],((int16_t*)&prod_im[aa])[6],((int16_t*)&prod_im[aa])[7], - ((int16_t*)&prod_im[aa])[8],((int16_t*)&prod_im[aa])[9],((int16_t*)&prod_im[aa])[10],((int16_t*)&prod_im[aa])[11], - ((int16_t*)&prod_im[aa])[12],((int16_t*)&prod_im[aa])[13],((int16_t*)&prod_im[aa])[14],((int16_t*)&prod_im[aa])[15]); - + printf("prod_re[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\n",aa, + ((int16_t*)&prod_re[aa])[0],((int16_t*)&prod_re[aa])[1],((int16_t*)&prod_re[aa])[2],((int16_t*)&prod_re[aa])[3], + ((int16_t*)&prod_re[aa])[4],((int16_t*)&prod_re[aa])[5],((int16_t*)&prod_re[aa])[6],((int16_t*)&prod_re[aa])[7], + ((int16_t*)&prod_re[aa])[8],((int16_t*)&prod_re[aa])[9],((int16_t*)&prod_re[aa])[10],((int16_t*)&prod_re[aa])[11], + ((int16_t*)&prod_re[aa])[12],((int16_t*)&prod_re[aa])[13],((int16_t*)&prod_re[aa])[14],((int16_t*)&prod_re[aa])[15]); + printf("prod_im[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\n",aa, + ((int16_t*)&prod_im[aa])[0],((int16_t*)&prod_im[aa])[1],((int16_t*)&prod_im[aa])[2],((int16_t*)&prod_im[aa])[3], + ((int16_t*)&prod_im[aa])[4],((int16_t*)&prod_im[aa])[5],((int16_t*)&prod_im[aa])[6],((int16_t*)&prod_im[aa])[7], + ((int16_t*)&prod_im[aa])[8],((int16_t*)&prod_im[aa])[9],((int16_t*)&prod_im[aa])[10],((int16_t*)&prod_im[aa])[11], + ((int16_t*)&prod_im[aa])[12],((int16_t*)&prod_im[aa])[13],((int16_t*)&prod_im[aa])[14],((int16_t*)&prod_im[aa])[15]); + #endif - prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1 - prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); - prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3 - prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); - prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7 - prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); - prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15 - prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); - } - int64_t corr_re=0,corr_im=0; + prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1 + prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); + prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3 + prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); + prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7 + prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); + prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15 + prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]); + } + int64_t corr_re=0,corr_im=0; - for (int aa=0;aa corr) { - corr = corr_tmp; - cw_ML=cw; + corr = corr_tmp; + cw_ML=cw; } } // cw loop corr_dB = dB_fixed64((uint64_t)corr); +#ifdef DEBUG_NR_PUCCH_RX + printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB); +#endif LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); decodedPayload[0]=(uint64_t)cw_ML; } else { // polar coded case t_nrPolar_params *currentPtr = nr_polar_params(2,nb_bit,pucch_pdu->prb_size,1,&gNB->uci_polarParams); - __m64 *rp_re[Prx2]; - __m64 *rp2_re[Prx2]; - __m64 *rp_im[Prx2]; - __m64 *rp2_im[Prx2]; - __m128i llrs[pucch_pdu->prb_size*2]; + __m64 *rp_re[Prx2][2]; + __m64 *rp2_re[Prx2][2]; + __m64 *rp_im[Prx2][2]; + __m64 *rp2_im[Prx2][2]; + __m128i llrs[pucch_pdu->prb_size*2*pucch_pdu->nr_of_symbols]; for (int aa=0;aanr_of_symbols;symb++) { + rp_re[aa][symb] = (__m64*)r_re_ext[aa][symb]; + rp_im[aa][symb] = (__m64*)r_im_ext[aa][symb]; + rp2_re[aa][symb] = (__m64*)r_re_ext2[aa][symb]; + rp2_im[aa][symb] = (__m64*)r_im_ext2[aa][symb]; + } } __m64 prod_re[Prx2],prod_im[Prx2]; @@ -1482,35 +1559,35 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, int32_t corr_re,corr_im,corr_tmp; __m128i corr16,llr_num,llr_den; uint64_t corr = 0; + for (int symb=0;symbnr_of_symbols;symb++) { + for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) { + llr_num=_mm_set1_epi16(0);llr_den=_mm_set1_epi16(0); + for (int cw=0;cw<256;cw++) { + corr_tmp=0; + for (int aa=0;aa>4],rp_im[aa][symb][half_prb])),5); + prod_im[aa] = _mm_srai_pi16(_mm_subs_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp2_im[aa][symb][half_prb]), + _mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp2_re[aa][symb][half_prb])),5); + prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1 + prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); + prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3 + prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); - for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) { - llr_num=_mm_set1_epi16(0);llr_den=_mm_set1_epi16(0); - for (int cw=0;cw<256;cw++) { - corr_tmp=0; - for (int aa=0;aa>4],rp_im[aa][half_prb])),5); - prod_im[aa] = _mm_srai_pi16(_mm_subs_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp2_im[aa][half_prb]), - _mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp2_re[aa][half_prb])),5); - prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1 - prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); - prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3 - prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); - - // this is for UL CQI measurement - if (cw==0) corr += ((int64_t)corr32_re[half_prb>>2][aa]*corr32_re[half_prb>>2][aa])+ - ((int64_t)corr32_im[half_prb>>2][aa]*corr32_im[half_prb>>2][aa]); + // this is for UL CQI measurement + if (cw==0) corr += ((int64_t)corr32_re[symb][half_prb>>2][aa]*corr32_re[symb][half_prb>>2][aa])+ + ((int64_t)corr32_im[symb][half_prb>>2][aa]*corr32_im[symb][half_prb>>2][aa]); - corr_re = ( corr32_re[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]); - corr_im = ( corr32_im[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]); - corr_tmp += corr_re*corr_re + corr_im*corr_im; - - LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n", - half_prb,cw,cw&15,cw>>4,aa, - ((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0], - ((int16_t*)&pucch2_polar_4bit[cw&15])[1],((int16_t*)&pucch2_polar_4bit[cw>>4])[1], - ((int16_t*)&pucch2_polar_4bit[cw&15])[2],((int16_t*)&pucch2_polar_4bit[cw>>4])[2], + corr_re = ( corr32_re[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]); + corr_im = ( corr32_im[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]); + corr_tmp += corr_re*corr_re + corr_im*corr_im; + /* + LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n", + half_prb,cw,cw&15,cw>>4,aa, + ((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0], + ((int16_t*)&pucch2_polar_4bit[cw&15])[1],((int16_t*)&pucch2_polar_4bit[cw>>4])[1], + ((int16_t*)&pucch2_polar_4bit[cw&15])[2],((int16_t*)&pucch2_polar_4bit[cw>>4])[2], ((int16_t*)&pucch2_polar_4bit[cw&15])[3],((int16_t*)&pucch2_polar_4bit[cw>>4])[3], ((int16_t*)&rp_re[aa][half_prb])[0],((int16_t*)&rp_im[aa][half_prb])[0], ((int16_t*)&rp_re[aa][half_prb])[1],((int16_t*)&rp_im[aa][half_prb])[1], @@ -1522,7 +1599,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, corr_re, corr_im, corr_tmp); - +*/ } corr16 = _mm_set1_epi16((int16_t)(corr_tmp>>8)); @@ -1562,18 +1639,19 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } // compute llrs - llrs[half_prb] = _mm_subs_epi16(llr_num,llr_den); - LOG_D(PHY,"llrs[%d] : (%d,%d,%d,%d,%d,%d,%d,%d)\n", - half_prb, - ((int16_t*)&llrs[half_prb])[0], - ((int16_t*)&llrs[half_prb])[1], - ((int16_t*)&llrs[half_prb])[2], - ((int16_t*)&llrs[half_prb])[3], - ((int16_t*)&llrs[half_prb])[4], - ((int16_t*)&llrs[half_prb])[5], - ((int16_t*)&llrs[half_prb])[6], - ((int16_t*)&llrs[half_prb])[7]); - } // half_prb + llrs[half_prb + (symb*2*pucch_pdu->prb_size)] = _mm_subs_epi16(llr_num,llr_den); + LOG_D(PHY,"llrs[%d] : (%d,%d,%d,%d,%d,%d,%d,%d)\n", + half_prb, + ((int16_t*)&llrs[half_prb])[0], + ((int16_t*)&llrs[half_prb])[1], + ((int16_t*)&llrs[half_prb])[2], + ((int16_t*)&llrs[half_prb])[3], + ((int16_t*)&llrs[half_prb])[4], + ((int16_t*)&llrs[half_prb])[5], + ((int16_t*)&llrs[half_prb])[6], + ((int16_t*)&llrs[half_prb])[7]); + } // half_prb + } // symb // run polar decoder on llrs decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr); LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]); @@ -1582,9 +1660,10 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, LOG_D(PHY,"metric %d dB\n",corr_dB); } - re_offset = (12*pucch_pdu->prb_start) + (12*pucch_pdu->bwp_start) + frame_parms->first_carrier_offset; - // estimate CQI for MAC (from antenna port 0 only) - int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][(l2*frame_parms->ofdm_symbol_size)+re_offset],12*pucch_pdu->prb_size)) - (10*gNB->measurements.n0_power_tot_dB); + // estimate CQI for MAC (from antenna port 0 only) + int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]], + 12*pucch_pdu->prb_size)) - + (10*gNB->measurements.n0_power_tot_dB); int cqi,bit_left; if (SNRtimes10 < -640) cqi=0; else if (SNRtimes10 > 635) cqi=255; @@ -1597,7 +1676,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uci_pdu->pucch_format=0; uci_pdu->ul_cqi=cqi; uci_pdu->timing_advance=0xffff; // currently not valid - uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][(l2*frame_parms->ofdm_symbol_size)+re_offset],12*pucch_pdu->prb_size))); + uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size))); if (pucch_pdu->bit_len_harq>0) { int harq_bytes=pucch_pdu->bit_len_harq>>3; if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 44f1844ae9..7f6f0e8ef9 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -36,7 +36,6 @@ #include "PHY/phy_extern_nr_ue.h" #include "common/utils/LOG/log.h" #include "PHY/sse_intrin.h" -#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" //#define k1 1000 #define k1 ((long long int) 1000) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index aa8588f106..3afe27310f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -36,16 +36,14 @@ #include #endif -#include -#include -#include "executables/softmodem-common.h" +#include "executables/softmodem-common.h" #include "nr_transport_proto_ue.h" #include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/CODING/coding_extern.h" #include "PHY/sse_intrin.h" -#include "PHY/NR_TRANSPORT/nr_dci.h" +#include "common/utils/nr/nr_common.h" #include "assertions.h" #include "T.h" @@ -148,7 +146,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, } - int f_bundle_j_list[NR_MAX_PDCCH_AGG_LEVEL] = {}; + int f_bundle_j_list[(2*NR_MAX_PDCCH_AGG_LEVEL) - 1] = {}; for (int reg = 0; reg < coreset_nbr_rb; reg++) { if ((reg % reg_bundle_size_L) == 0) { @@ -170,12 +168,14 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, // Get cce_list indices by reg_idx in ascending order int f_bundle_j_list_id = 0; - int f_bundle_j_list_ord[NR_MAX_PDCCH_AGG_LEVEL] = {}; + int f_bundle_j_list_ord[(2*NR_MAX_PDCCH_AGG_LEVEL)-1] = {}; for (int c_id = 0; c_id < number_of_candidates; c_id++ ) { f_bundle_j_list_id = CCE[c_id]; for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) { for (int p2 = CCE[c_id]; p2 < CCE[c_id] + L[c_id]; p2++) { + AssertFatal(p2<2*NR_MAX_PDCCH_AGG_LEVEL,"number_of_candidates %d : p2 %d, CCE[%d] %d, L[%d] %d\n",number_of_candidates,p2,c_id,CCE[c_id],c_id,L[c_id]); if (f_bundle_j_list[p2] == p) { + AssertFatal(f_bundle_j_list_id < 2*NR_MAX_PDCCH_AGG_LEVEL,"f_bundle_j_list_id %d\n",f_bundle_j_list_id); f_bundle_j_list_ord[f_bundle_j_list_id] = p; f_bundle_j_list_id++; break; @@ -413,7 +413,6 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, * we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF */ - LOG_DDD("n_BWP_start=%d, coreset_nbr_rb=%d\n",n_BWP_start,coreset_nbr_rb); int c_rb_by6; c_rb = 0; for (int rb=0;rb>2; rb++) { - //printf("rb %d\n",rb); #if defined(__x86_64__) || defined(__i386__) // multiply by conjugated channel mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpP0); + //print_ints("re",&mmtmpP0); // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i *)&conjugate[0]); - // print_ints("im",&mmtmpP1); + //print_ints("im",&mmtmpP1); mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]); // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); @@ -599,12 +597,12 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, // print_ints("im(shift)",&mmtmpP1); mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - // print_ints("c0",&mmtmpP2); - // print_ints("c1",&mmtmpP3); + //print_ints("c0",&mmtmpP2); + //print_ints("c1",&mmtmpP3); rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - //print_shorts("rx:",rxdataF128); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rxdataF_comp128); +// print_shorts("rx:",(int16_t*)rxdataF128); +// print_shorts("ch:",(int16_t*)dl_ch128); +// print_shorts("pack:",(int16_t*)rxdataF_comp128); // multiply by conjugated channel mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) @@ -800,7 +798,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #endif } - LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving()\n"); + LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving(), number of candidates %d\n",rel15->number_of_candidates); nr_pdcch_demapping_deinterleaving((uint32_t *) pdcch_vars->llr, (uint32_t *) pdcch_vars->e_rx, rel15->coreset.duration, @@ -933,11 +931,22 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, // Loop over possible DCI lengths for (int k = 0; k < rel15->num_dci_options; k++) { + // skip this candidate if we've already found one with the + // same rnti and format at a different aggregation level + int dci_found=0; + for (int ind=0;ind < dci_ind->number_of_dcis ; ind++) { + if (rel15->rnti== dci_ind->dci_list[ind].rnti && + rel15->dci_format_options[k]==dci_ind->dci_list[ind].dci_format) { + dci_found=1; + break; + } + } + if (dci_found==1) continue; int dci_length = rel15->dci_length_options[k]; uint64_t dci_estimation[2]= {0}; const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList); - LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L); + LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L, dci_length,nr_dci_format_string[rel15->dci_format_options[k]]); nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index fa09093306..8a4cafc6d7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -45,11 +45,6 @@ //#define DEBUG_HARQ -//#include "LAYER2/MAC/extern.h" -//#include "LAYER2/MAC/defs.h" -//#include "../openair2/LAYER2/MAC/extern.h" -//#include "../openair2/LAYER2/MAC/defs.h" - //#define DEBUG_DCI #define NR_PDCCH_DCI_TOOLS //#define NR_PDCCH_DCI_TOOLS_DEBUG diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 95b04435eb..975d7077a0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -43,7 +43,7 @@ #include "SIMULATION/TOOLS/sim.h" #include "executables/nr-uesoftmodem.h" #include "PHY/CODING/nrLDPC_extern.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include "common/utils/nr/nr_common.h" //#define ENABLE_PHY_PAYLOAD_DEBUG 1 @@ -236,11 +236,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint8_t harq_pid, uint8_t is_crnti, uint8_t llr8_flag) { -#if UE_TIMING_TRACE time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats; time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats; time_stats_t *dlsch_deinterleaving_stats=&phy_vars_ue->dlsch_deinterleaving_stats; -#endif + uint32_t A,E; uint32_t G; uint32_t ret,offset; @@ -328,8 +327,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); G = harq_process->G; - LOG_D(PHY,"DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n", - harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n", + frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); if ((harq_process->R)<1024) Coderate = (float) (harq_process->R) /(float) 1024; @@ -411,21 +410,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, for (r=0; rC; r++) { //printf("start rx segment %d\n",r); E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); -#if UE_TIMING_TRACE start_meas(dlsch_deinterleaving_stats); -#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); nr_deinterleaving_ldpc(E, harq_process->Qm, harq_process->w[r], // [hna] w is e dlsch_llr+r_offset); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); -#endif -#if UE_TIMING_TRACE start_meas(dlsch_rate_unmatching_stats); -#endif LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,E %d, F %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", harq_pid,r, G,E,harq_process->F, Kr*3, @@ -454,16 +447,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, E, harq_process->F, Kr-harq_process->F-2*(p_decParams->Z))==-1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(dlsch_rate_unmatching_stats); -#endif - LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); - return(dlsch->max_ldpc_iterations + 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT); + stop_meas(dlsch_rate_unmatching_stats); + LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); + return(dlsch->max_ldpc_iterations + 1); } else { -#if UE_TIMING_TRACE - stop_meas(dlsch_rate_unmatching_stats); -#endif + stop_meas(dlsch_rate_unmatching_stats); } r_offset += E; @@ -492,9 +481,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } if (err_flag == 0) { -#if UE_TIMING_TRACE start_meas(dlsch_turbo_decoding_stats); -#endif //set first 2*Z_c bits to zeros memset(&z[0],0,2*harq_process->Z*sizeof(int16_t)); //set Filler bits @@ -510,6 +497,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN); + p_decParams->block_length=length_dec; + nrLDPC_initcall(p_decParams, (int8_t*)&pl[0], llrProcBuf); no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t *)&pl[0], llrProcBuf, @@ -545,13 +534,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { for (int k=0; k>3; k++) LOG_D(PHY,"output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); - LOG_D(PHY,"no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret); } -#if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); -#endif } if ((err_flag == 0) && (ret>=(1+dlsch->max_ldpc_iterations))) {// a Code segment is in error so break; @@ -645,11 +631,10 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, uint8_t harq_pid, uint8_t is_crnti, uint8_t llr8_flag) { -#if UE_TIMING_TRACE + time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats; time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats; time_stats_t *dlsch_deinterleaving_stats=&phy_vars_ue->dlsch_deinterleaving_stats; -#endif uint32_t A,E; uint32_t G; uint32_t ret,offset; @@ -812,7 +797,6 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *res_dl; opp_enabled=1; - if (harq_process->C>1) { for (int nb_seg =1 ; nb_segC; nb_seg++) { if ( (res_dl=tryPullTpool(&nf, &pool_dl)) != NULL ) { @@ -867,9 +851,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, dlsch_llr+r_offset, &harq_process->w[r]); */ -#if UE_TIMING_TRACE start_meas(dlsch_deinterleaving_stats); -#endif nr_deinterleaving_ldpc(E, harq_process->Qm, harq_process->w[r], @@ -879,12 +861,8 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, for (int i =0; i<16; i++) LOG_D(PHY,"rx output deinterleaving w[%d]= %d r_offset %u\n", i,harq_process->w[r][i], r_offset); -#if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); -#endif -#if UE_TIMING_TRACE start_meas(dlsch_rate_unmatching_stats); -#endif if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) LOG_I(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", @@ -915,15 +893,11 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, E, harq_process->F, Kr-harq_process->F-2*(p_decParams->Z))==-1) { -#if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); -#endif LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); return(dlsch->max_ldpc_iterations); } else { -#if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); -#endif } if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) @@ -966,9 +940,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS, harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations); */ -#if UE_TIMING_TRACE start_meas(dlsch_turbo_decoding_stats); -#endif LOG_D(PHY,"mthread AbsSubframe %d.%d Start LDPC segment %d/%d \n",frame%1024,nr_slot_rx,r,harq_process->C-1); /*for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ inv_d[cnt] = (1)*harq_process->d[r][cnt]; @@ -986,7 +958,8 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) { pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); } - + p_decParams->block_length=length_dec; + nrLDPC_initcall(p_decParams, (int8_t*)&pl[0], llrProcBuf); no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t *)&pl[0], llrProcBuf, @@ -1037,11 +1010,10 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, for (int k=0; k<32; k++) LOG_D(PHY,"output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); -#if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); -#endif } + if ((err_flag == 0) && (ret>=(1+dlsch->max_ldpc_iterations))) {// a Code segment is in error so break; LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_slot_rx,r,harq_process->C-1); err_flag = 1; @@ -1135,7 +1107,6 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, } - void nr_dlsch_decoding_process(void *arg) { nr_rxtx_thread_data_t *rxtxD= (nr_rxtx_thread_data_t *)arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; @@ -1167,11 +1138,10 @@ void nr_dlsch_decoding_process(void *arg) { proc->instance_cnt_dlsch_td=-1; //proc->nr_slot_rx = proc->sub_frame_start * frame_parms->slots_per_subframe; proc->decoder_thread_available = 1; -#if UE_TIMING_TRACE time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats; time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats; time_stats_t *dlsch_deinterleaving_stats=&phy_vars_ue->dlsch_deinterleaving_stats; -#endif + uint32_t A,E; uint32_t G; uint32_t ret; @@ -1200,7 +1170,8 @@ void nr_dlsch_decoding_process(void *arg) { ret = dlsch->max_ldpc_iterations; harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl); G = harq_process->G; - LOG_D(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + + LOG_D(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d, Coderate %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb,harq_process->R); if ((harq_process->R)<1024) Coderate = (float) (harq_process->R) /(float) 1024; @@ -1271,9 +1242,7 @@ void nr_dlsch_decoding_process(void *arg) { Kr_bytes = Kr>>3; K_bits_F = Kr-harq_process->F; E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); -#if UE_TIMING_TRACE start_meas(dlsch_deinterleaving_stats); -#endif nr_deinterleaving_ldpc(E, harq_process->Qm, harq_process->w[r], @@ -1283,13 +1252,8 @@ void nr_dlsch_decoding_process(void *arg) { for (int i =0; i<16; i++) LOG_D(PHY,"rx output thread 0 deinterleaving w[%d]= %d r_offset %u\n", i,harq_process->w[r][i], r_offset); -#if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); -#endif -#if UE_TIMING_TRACE start_meas(dlsch_rate_unmatching_stats); -#endif - if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) LOG_I(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", harq_pid,r, G, @@ -1318,15 +1282,11 @@ void nr_dlsch_decoding_process(void *arg) { E, harq_process->F, Kr-harq_process->F-2*(p_decParams->Z))==-1) { -#if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); -#endif LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); //return(dlsch->max_ldpc_iterations); } else { -#if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); -#endif } if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { @@ -1363,9 +1323,7 @@ void nr_dlsch_decoding_process(void *arg) { Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); } -#if UE_TIMING_TRACE start_meas(dlsch_turbo_decoding_stats); -#endif // LOG_D(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1); /* for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ @@ -1385,7 +1343,8 @@ void nr_dlsch_decoding_process(void *arg) { for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) { pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); } - + p_decParams->block_length=length_dec; + nrLDPC_initcall(p_decParams, (int8_t*)&pl[0], llrProcBuf); no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t *)&pl[0], llrProcBuf, @@ -1411,10 +1370,7 @@ void nr_dlsch_decoding_process(void *arg) { if ( LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) for (int k=0; k<2; k++) LOG_D(PHY,"segment 1 output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); - -#if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); -#endif } if ((err_flag == 0) && (ret>=(1+dlsch->max_ldpc_iterations))) {// a Code segment is in error so break; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index fb6e7bf6b5..031c08a72d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -41,6 +41,7 @@ #include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/NR_REFSIG/dmrs_nr.h" +#include "common/utils/nr/nr_common.h" #ifndef USER_MODE #define NOCYGWIN_STATIC static @@ -163,9 +164,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, // int avg_0[2]; // int avg_1[2]; -#if UE_TIMING_TRACE uint8_t slot = 0; -#endif unsigned char aatx=0,aarx=0; @@ -331,12 +330,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, DevAssert(dlsch1_harq); } -#if UE_TIMING_TRACE if(symbol > ue->frame_parms.symbols_per_slot>>1) { slot = 1; } -#endif #ifdef DEBUG_HARQ printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc); @@ -346,9 +343,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, uint8_t config_type = dlsch0_harq->dmrsConfigType; if (beamforming_mode==0) {//No beamforming -#if UE_TIMING_TRACE start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif if (dlsch0_harq->Nl > 1)//More than or equal 2 layers nb_rb = nr_dlsch_extract_rbs_multiple(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, pdsch_vars[gNB_id]->dl_ch_estimates, @@ -389,7 +384,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, len = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb*(12-4*dlsch0_harq->n_dmrs_cdm_groups)):(nb_rb*12); -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", @@ -398,11 +392,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif -#if UE_TIMING_TRACE start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif n_tx = dlsch0_harq->Nl; n_rx = frame_parms->nb_antennas_rx; @@ -416,18 +407,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, len, nb_rb_pdsch); -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif - -#if UE_TIMING_TRACE start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif if (first_symbol_flag==1) { if (beamforming_mode==0){ nr_dlsch_channel_level(pdsch_vars[gNB_id]->dl_ch_estimates_ext, @@ -482,19 +468,14 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } #endif -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif - -#if UE_TIMING_TRACE start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif // Now channel compensation if (dlsch0_harq->mimo_moderxdataF_ext, @@ -539,18 +520,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, 0); } -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif -// MRC -#if UE_TIMING_TRACE start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif if (frame_parms->nb_antennas_rx > 1) { if (dlsch0_harq->mimo_modegeneric_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif - -#if UE_TIMING_TRACE - start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#endif /* Store the valid DL RE's */ pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = len; @@ -692,14 +662,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if DISABLE_LOG_X printf("[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); #endif -#endif // Please keep it: useful for debugging #ifdef DEBUG_PDSCH_RX diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 7dfd765b76..ffe21b1f6d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -38,6 +38,7 @@ #include "PHY/NR_UE_ESTIMATION/nr_estimation.h" #include "SCHED_NR_UE/defs.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "common/utils/nr/nr_common.h" #include "common_lib.h" #include @@ -126,15 +127,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini // initialization of structure current_ssb = create_ssb_node(l,hf); -#if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); -#endif // computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); -#endif current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im*current_ssb->c_im; @@ -150,15 +147,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini NR_UE_SSB *temp_ptr=best_ssb; while (ret!=0 && temp_ptr != NULL) { -#if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); -#endif // computing channel estimation for selected best ssb for(int i=pbch_initial_symbol; ii_ssb,temp_ptr->n_hf); -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); -#endif ret = nr_rx_pbch(ue, proc, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index d94ae2a61e..5487d30968 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -39,7 +39,6 @@ #include "PHY/CODING/nrLDPC_extern.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include //#define DEBUG_ULSCH_CODING diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index bcce28b390..98ebecb9c8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -44,8 +44,6 @@ #include "PHY/TOOLS/tools_defs.h" #include "executables/nr-softmodem.h" #include "executables/softmodem-common.h" -#include "LAYER2/NR_MAC_UE/mac_proto.h" - #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" #include @@ -144,7 +142,12 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ulsch_ue->Nid_cell = Nid_cell; - get_num_re_dmrs(pusch_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols); + for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { + if((ul_dmrs_symb_pos >> i) & 0x01) + number_dmrs_symbols += 1; + } + + nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data; LOG_D(PHY,"ulsch %x : start_rb %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_re_per_rb %d\n", rnti,start_rb,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 61bca6f409..68d8735411 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -34,7 +34,6 @@ #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" //#include "PHY/extern.h" -//#include "LAYER2/MAC/extern.h" #include "PHY/NR_UE_TRANSPORT/pucch_nr.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" @@ -91,7 +90,7 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1 uint8_t u[2]={0,0},v[2]={0,0}; - LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, mcs %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->mcs); + LOG_D(PHY,"pucch0: slot %d nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, mcs %d\n",nr_slot_tx,pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->mcs); #ifdef DEBUG_NR_PUCCH_TX diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h index dcf7fb4a37..078a95605f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h @@ -37,7 +37,6 @@ #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" //#include "PHY/extern.h" -//#include "LAYER2/MAC/extern.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index 001770c876..c62fbed106 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -18,17 +18,27 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - +#define _GNU_SOURCE #include #include "time_meas.h" #include #include - +#include +#include "assertions.h" +#ifndef PHYSIM + #include + #include "common/config/config_userapi.h" +#endif // global var for openair performance profiler int opp_enabled = 0; double cpu_freq_GHz __attribute__ ((aligned(32))); double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0; +#ifndef PHYSIM +static uint32_t max_cpumeasur; +static time_stats_t **measur_table; +notifiedFIFO_t measur_fifo; +#endif double get_cpu_freq_GHz(void) { if (cpu_freq_GHz <1 ) { @@ -64,8 +74,8 @@ int cpumeas(int action) } void print_meas_now(time_stats_t *ts, - const char *name, - FILE *file_name) + const char *name, + FILE *file_name) { if (opp_enabled) { //static double cpu_freq_GHz = 3.2; @@ -80,9 +90,9 @@ void print_meas_now(time_stats_t *ts, } void print_meas(time_stats_t *ts, - const char *name, - time_stats_t *total_exec_time, - time_stats_t *sf_exec_time) + const char *name, + time_stats_t *total_exec_time, + time_stats_t *sf_exec_time) { if (opp_enabled) { static int first_time = 0; @@ -133,3 +143,112 @@ double get_time_meas_us(time_stats_t *ts) return 0; } + +#ifndef PHYSIM +/* function for the asynchronous measurment module: cpu stat are sent to a dedicated thread + * which is in charge of computing the cpu time spent in a given function/algorithm... + */ + +time_stats_t *register_meas(char *name) +{ + for (int i=0; imeas_name = strdup(name); + measur_table[i]->meas_index = i; + measur_table[i]->tpoolmsg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL); + measur_table[i]->tstatptr = (time_stats_msg_t *)NotifiedFifoData(measur_table[i]->tpoolmsg); + return measur_table[i]; + } + } + return NULL; +} + +void free_measurtbl(void) { + for (int i=0; imeas_name); + delNotifiedFIFO_elt(measur_table[i]->tpoolmsg); + free(measur_table[i]); + } + } + //free the fifo... +} + +void run_cpumeasur(void) { + struct sched_param schedp; + pthread_setname_np(pthread_self(), "measur"); + schedp.sched_priority=0; + int rt=pthread_setschedparam(pthread_self(), SCHED_IDLE, &schedp); + AssertFatal(rt==0, "couldn't set measur thread priority: %s\n",strerror(errno)); + initNotifiedFIFO(&measur_fifo); + while(1) { + notifiedFIFO_elt_t *msg = pullNotifiedFIFO(&measur_fifo); + time_stats_msg_t *tsm = (time_stats_msg_t *)NotifiedFifoData(msg); + switch(tsm->msgid) { + case TIMESTAT_MSGID_START: + measur_table[tsm->timestat_id]->in=tsm->ts; + (measur_table[tsm->timestat_id]->trials)++; + break; + case TIMESTAT_MSGID_STOP: + /// process duration is the difference between two clock points + measur_table[tsm->timestat_id]->p_time = (tsm->ts - measur_table[tsm->timestat_id]->in); + measur_table[tsm->timestat_id]->diff += measur_table[tsm->timestat_id]->p_time; + if ( measur_table[tsm->timestat_id]->p_time > measur_table[tsm->timestat_id]->max ) + measur_table[tsm->timestat_id]->max = measur_table[tsm->timestat_id]->p_time; + break; + case TIMESTAT_MSGID_DISPLAY: + { + char aline[256]; + int start, stop; + if (tsm->displayFunc != NULL) { + if(tsm->timestat_id >= 0) { + start=tsm->timestat_id ; + stop=start+1; + } + else { + start=0; + stop=max_cpumeasur ; + } + for (int i=start ; imeas_name, measur_table[i]->trials==0?0:( (measur_table[i]->trials/measur_table[i]->diff )/ cpu_freq_GHz /1000 )); + tsm->displayFunc(aline); + } + } + } + } + break; + case TIMESTAT_MSGID_END: + free_measurtbl(); + delNotifiedFIFO_elt(msg); + pthread_exit(NULL); + break; + default: + break; + } + delNotifiedFIFO_elt(msg); + } +} + + +void init_meas(void) { + pthread_t thid; + paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC; + int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t); + int rt = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION); + AssertFatal(rt >= 0, "cpumeasur configuration couldn't be performed"); + measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *)); + AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur); + rt=pthread_create(&thid,NULL, (void *(*)(void *))run_cpumeasur, NULL); + AssertFatal(rt==0, "couldn't create cpu measurment thread: %s\n",strerror(errno)); +} + +void end_meas(void) { + notifiedFIFO_elt_t *nfe = newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL); + time_stats_msg_t *msg = (time_stats_msg_t *)NotifiedFifoData(nfe); + msg->msgid = TIMESTAT_MSGID_END ; + pushNotifiedFIFO(&measur_fifo, nfe); +} +#endif diff --git a/openair1/PHY/TOOLS/time_meas.h b/openair1/PHY/TOOLS/time_meas.h index e2ceef8405..f78ea55530 100644 --- a/openair1/PHY/TOOLS/time_meas.h +++ b/openair1/PHY/TOOLS/time_meas.h @@ -31,31 +31,57 @@ #include #include #include +#ifndef PHYSIM + #include "common/utils/threadPool/thread-pool.h" +#endif // global var to enable openair performance profiler extern int opp_enabled; extern double cpu_freq_GHz __attribute__ ((aligned(32)));; - +// structure to store data to compute cpu measurment #if defined(__x86_64__) || defined(__i386__) -typedef struct { - long long in; - long long diff; - long long p_time; /*!< \brief absolute process duration */ - long long diff_square; /*!< \brief process duration square */ - long long max; - int trials; - int meas_flag; -} time_stats_t; + #define OAI_CPUTIME_TYPE long long #elif defined(__arm__) -typedef struct { - uint32_t in; - uint32_t diff; - uint32_t p_time; /*!< \brief absolute process duration */ - uint32_t diff_square; /*!< \brief process duration square */ - uint32_t max; - int trials; -} time_stats_t; + #define OAI_CPUTIME_TYPE uint32_t +#else + #error "building on unsupported CPU architecture" #endif +#define TIMESTAT_MSGID_START 0 /*!< \brief send time at measure starting point */ +#define TIMESTAT_MSGID_STOP 1 /*!< \brief send time at measure end point */ +#define TIMESTAT_MSGID_ENABLE 2 /*!< \brief enable measure point */ +#define TIMESTAT_MSGID_DISABLE 3 /*!< \brief disable measure point */ +#define TIMESTAT_MSGID_DISPLAY 10 /*!< \brief display measure */ +#define TIMESTAT_MSGID_END 11 /*!< \brief stops the measure threads and free assocated resources */ +typedef void(*meas_printfunc_t)(const char* format, ...); +typedef struct { + int msgid; /*!< \brief message id, as defined by TIMESTAT_MSGID_X macros */ + int timestat_id; /*!< \brief points to the time_stats_t entry in cpumeas table */ + OAI_CPUTIME_TYPE ts; /*!< \brief time stamp */ + meas_printfunc_t displayFunc; /*!< \brief function to call when DISPLAY message is received*/ +} time_stats_msg_t; + + +typedef struct { + OAI_CPUTIME_TYPE in; /*!< \brief time at measure starting point */ + OAI_CPUTIME_TYPE diff; /*!< \brief average difference between time at starting point and time at endpoint*/ + OAI_CPUTIME_TYPE p_time; /*!< \brief absolute process duration */ + OAI_CPUTIME_TYPE diff_square; /*!< \brief process duration square */ + OAI_CPUTIME_TYPE max; /*!< \brief maximum difference between time at starting point and time at endpoint*/ + int trials; /*!< \brief number of start point - end point iterations */ + int meas_flag; /*!< \brief 1: stop_meas not called (consecutive calls of start_meas) */ + char *meas_name; /*!< \brief name to use when printing the measure (not used for PHY simulators)*/ + int meas_index; /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/ + int meas_enabled; /*!< \brief per measure enablement flag. send_meas tests this flag, unused today in start_meas and stop_meas*/ +#ifndef PHYSIM + notifiedFIFO_elt_t *tpoolmsg; /*!< \brief message pushed to the cpu measurment queue to report a measure START or STOP */ + time_stats_msg_t *tstatptr; /*!< \brief pointer to the time_stats_msg_t data in the tpoolmsg, stored here for perf considerations*/ +#endif +} time_stats_t; +#define MEASURE_ENABLED(X) (X->meas_enabled) + + + + static inline void start_meas(time_stats_t *ts) __attribute__((always_inline)); static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline)); @@ -137,4 +163,28 @@ static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) { dst_ts->max=src_ts->max; } } + +#ifndef PHYSIM +extern notifiedFIFO_t measur_fifo; +#define CPUMEASUR_SECTION "cpumeasur" + +#define CPUMEASUR_PARAMS_DESC { \ + {"max_cpumeasur", "Max number of cpu measur entries", 0, uptr:&max_cpumeasur, defintval:100, TYPE_UINT, 0},\ + } + + void init_meas(void); + time_stats_t *register_meas(char *name); + #define START_MEAS(X) send_meas(X, TIMESTAT_MSGID_START) + #define STOP_MEAS(X) send_meas(X, TIMESTAT_MSGID_STOP) + static inline void send_meas(time_stats_t *ts, int msgid) { + if (MEASURE_ENABLED(ts) ) { + ts->tstatptr->timestat_id=ts->meas_index; + ts->tstatptr->msgid = msgid ; + ts->tstatptr->ts = rdtsc_oai(); + pushNotifiedFIFO(&measur_fifo, ts->tpoolmsg); + } + } + void end_meas(void); + +#endif //ifndef PHYSIM #endif diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 66cb51adc6..76dd92ef5d 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -762,6 +762,7 @@ typedef struct RRU_config_s { typedef struct processingData_RU { int frame_tx; int slot_tx; + int next_slot; openair0_timestamp timestamp_tx; RU_t *ru; } processingData_RU_t; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 778724218f..11b5112a6c 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -122,8 +122,6 @@ typedef struct { typedef struct { uint8_t active; - int frame; - int slot; nfapi_nr_dl_tti_csi_rs_pdu csirs_pdu; } NR_gNB_CSIRS_t; @@ -134,6 +132,8 @@ typedef struct { } NR_gNB_UL_PDCCH_t; typedef struct { + int frame; + int dump_frame; uint16_t rnti; int round_trials[8]; int total_bytes_tx; @@ -143,6 +143,7 @@ typedef struct { int power[NB_ANTENNAS_RX]; int noise_power[NB_ANTENNAS_RX]; int DTX; + int sync_pos; } NR_gNB_SCH_STATS_t; typedef struct { @@ -248,6 +249,8 @@ typedef struct { uint32_t slot; /// Index of current HARQ round for this DLSCH uint8_t round; + uint8_t ndi; + bool new_rx; /// Last TPC command uint8_t TPC; /// MIMO mode for this DLSCH @@ -659,31 +662,33 @@ typedef struct { //! estimated noise power (linear) unsigned int n0_power[MAX_NUM_RU_PER_gNB]; //! estimated noise power (dB) - unsigned short n0_power_dB[MAX_NUM_RU_PER_gNB]; + unsigned int n0_power_dB[MAX_NUM_RU_PER_gNB]; //! total estimated noise power (linear) unsigned int n0_power_tot; //! estimated avg noise power (dB) - unsigned short n0_power_tot_dB; + unsigned int n0_power_tot_dB; //! estimated avg noise power (dB) - short n0_power_tot_dBm; + int n0_power_tot_dBm; //! estimated avg noise power per RB per RX ant (lin) - unsigned short n0_subband_power[MAX_NUM_RU_PER_gNB][275]; + unsigned int n0_subband_power[MAX_NUM_RU_PER_gNB][275]; //! estimated avg noise power per RB per RX ant (dB) - unsigned short n0_subband_power_dB[MAX_NUM_RU_PER_gNB][275]; + unsigned int n0_subband_power_dB[MAX_NUM_RU_PER_gNB][275]; //! estimated avg subband noise power (dB) - unsigned short n0_subband_power_avg_dB; + unsigned int n0_subband_power_avg_dB; + //! estimated avg subband noise power per antenna (dB) + unsigned int n0_subband_power_avg_perANT_dB[NB_ANTENNAS_RX]; //! estimated avg noise power per RB (dB) - short n0_subband_power_tot_dB[275]; + int n0_subband_power_tot_dB[275]; //! estimated avg noise power per RB (dBm) - short n0_subband_power_tot_dBm[275]; + int n0_subband_power_tot_dBm[275]; // gNB measurements (per user) //! estimated received spatial signal power (linear) unsigned int rx_spatial_power[NUMBER_OF_NR_ULSCH_MAX][NB_ANTENNAS_TX][NB_ANTENNAS_RX]; //! estimated received spatial signal power (dB) - unsigned short rx_spatial_power_dB[NUMBER_OF_NR_ULSCH_MAX][NB_ANTENNAS_TX][NB_ANTENNAS_RX]; + unsigned int rx_spatial_power_dB[NUMBER_OF_NR_ULSCH_MAX][NB_ANTENNAS_TX][NB_ANTENNAS_RX]; //! estimated rssi (dBm) - short rx_rssi_dBm[NUMBER_OF_NR_ULSCH_MAX]; + int rx_rssi_dBm[NUMBER_OF_NR_ULSCH_MAX]; //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) int rx_correlation[NUMBER_OF_NR_ULSCH_MAX][2]; //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) @@ -759,7 +764,6 @@ typedef struct PHY_VARS_gNB_s { // nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu; // nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu; uint16_t num_pdsch_rnti[80]; - NR_gNB_SSB_t ssb[64]; NR_gNB_PBCH pbch; nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL]; NR_gNB_COMMON common_vars; @@ -767,7 +771,6 @@ typedef struct PHY_VARS_gNB_s { NR_gNB_PUSCH *pusch_vars[NUMBER_OF_NR_ULSCH_MAX]; NR_gNB_PUCCH_t *pucch[NUMBER_OF_NR_PUCCH_MAX]; NR_gNB_PDCCH_t pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; - NR_gNB_CSIRS_t csirs_pdu[NUMBER_OF_NR_CSIRS_MAX]; NR_gNB_UL_PDCCH_t ul_pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; NR_gNB_DLSCH_t *dlsch[NUMBER_OF_NR_DLSCH_MAX][2]; // Nusers times two spatial streams NR_gNB_ULSCH_t *ulsch[NUMBER_OF_NR_ULSCH_MAX][2]; // [Nusers times][2 codewords] @@ -804,9 +807,8 @@ typedef struct PHY_VARS_gNB_s { /// PUSCH DMRS uint32_t ****nr_gold_pusch_dmrs; - // Mask of occupied RBs - uint32_t rb_mask_ul[9]; - int ulmask_symb; + // Mask of occupied RBs, per symbol and PRB + uint32_t rb_mask_ul[14][9]; /// CSI RS sequence uint32_t ***nr_gold_csi_rs; @@ -851,10 +853,13 @@ typedef struct PHY_VARS_gNB_s { int pusch_thres; int prach_thres; uint64_t bad_pucch; + int num_ulprbbl; + int ulprbbl[275]; /* time_stats_t phy_proc; */ - time_stats_t phy_proc_tx; + time_stats_t *phy_proc_tx_0; + time_stats_t *phy_proc_tx_1; time_stats_t phy_proc_rx; time_stats_t rx_prach; /* @@ -946,4 +951,24 @@ typedef struct processingData_L1 { PHY_VARS_gNB *gNB; } processingData_L1_t; +typedef enum { + FILLED, + FILLING, + NOT_FILLED +} msgStatus_t; + +typedef struct processingData_L1tx { + int frame; + int slot; + openair0_timestamp timestamp_tx; + PHY_VARS_gNB *gNB; + nfapi_nr_dl_tti_pdcch_pdu pdcch_pdu; + nfapi_nr_ul_dci_request_pdus_t ul_pdcch_pdu; + NR_gNB_CSIRS_t csirs_pdu[NUMBER_OF_NR_CSIRS_MAX]; + NR_gNB_DLSCH_t *dlsch[NUMBER_OF_NR_DLSCH_MAX][2]; + NR_gNB_SSB_t ssb[64]; + uint16_t num_pdsch_slot; + time_stats_t phy_proc_tx; +} processingData_L1tx_t; + #endif diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index fa021ffe81..31b9899605 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -272,9 +272,14 @@ #define NB_NUMEROLOGIES_NR (5) #define TDD_CONFIG_NB_FRAMES (2) #define NR_MAX_SLOTS_PER_FRAME (160) /* number of slots per frame */ -#define NR_UE_CAPABILITY_SLOT_RX_TO_TX (6) /* FFS_NR_TODO it defines ue capability which is the number of slots */ - /* - between reception of pdsch and tarnsmission of its acknowlegment */ - /* - between reception of un uplink grant and its related transmission */ + +/* FFS_NR_TODO it defines ue capability which is the number of slots */ +/* - between reception of pdsch and tarnsmission of its acknowlegment */ +/* - between reception of un uplink grant and its related transmission */ +/* - FIXME temprarily set to 5 to avoid timing issues at OAI UE in rfsimulator */ +/* - issues caused by no rendez-vous point between TX and RX in the OAI UE */ +#define NR_UE_CAPABILITY_SLOT_RX_TO_TX (5) + #ifndef NO_RAT_NR #define DURATION_RX_TO_TX (NR_UE_CAPABILITY_SLOT_RX_TO_TX) /* for NR this will certainly depends to such UE capability which is not yet defined */ #else diff --git a/openair1/SCHED/nfapi_lte_dummy.c b/openair1/SCHED/nfapi_lte_dummy.c index 7d1e7e7684..4e82c3ecb3 100644 --- a/openair1/SCHED/nfapi_lte_dummy.c +++ b/openair1/SCHED/nfapi_lte_dummy.c @@ -13,11 +13,11 @@ void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){} int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){return 0;} -void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, - nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, +void handle_nr_nfapi_pdsch_pdu(processingData_L1tx_t *msgTx, + nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint8_t *sdu){ - } -void handle_nfapi_nr_csirs_pdu(PHY_VARS_gNB *gNB, +} +void handle_nfapi_nr_csirs_pdu(processingData_L1tx_t *msgTx, int frame, int slot, nfapi_nr_dl_tti_csi_rs_pdu *csirs_pdu){ } @@ -51,4 +51,5 @@ void nr_phy_config_request(NR_PHY_Config_t *gNB){} void install_nr_schedule_handlers(NR_IF_Module_t *if_inst){} -void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){} \ No newline at end of file +void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){} + diff --git a/openair1/SCHED/nfapi_nr_dummy.c b/openair1/SCHED/nfapi_nr_dummy.c index 1286a4e48a..511911723f 100644 --- a/openair1/SCHED/nfapi_nr_dummy.c +++ b/openair1/SCHED/nfapi_nr_dummy.c @@ -13,11 +13,11 @@ void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){} int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){return 0;} -void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, - nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, +void handle_nr_nfapi_pdsch_pdu(processingData_L1tx_t *msgTx, + nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint8_t *sdu){ - } -void handle_nfapi_nr_csirs_pdu(PHY_VARS_gNB *gNB, +} +void handle_nfapi_nr_csirs_pdu(processingData_L1tx_t *msgTx, int frame, int slot, nfapi_nr_dl_tti_csi_rs_pdu *csirs_pdu){ } @@ -53,4 +53,3 @@ void install_nr_schedule_handlers(NR_IF_Module_t *if_inst){} //void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){} - \ No newline at end of file diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index fa762fa5b8..8f315ba214 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -30,6 +30,7 @@ * \warning */ #include "fapi_nr_l1.h" +#include "common/ran_context.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_dci.h" @@ -43,7 +44,7 @@ extern int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req); extern uint8_t nfapi_mode; -void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, +void handle_nr_nfapi_ssb_pdu(processingData_L1tx_t *msgTx,int frame,int slot, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu) { @@ -53,11 +54,11 @@ void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, uint8_t i_ssb = dl_tti_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex; LOG_D(PHY,"%d.%d : ssb index %d pbch_pdu: %x\n",frame,slot,i_ssb,dl_tti_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload); - if (gNB->ssb[i_ssb].active) + if (msgTx->ssb[i_ssb].active) AssertFatal(1==0,"SSB PDU with index %d already active\n",i_ssb); else { - gNB->ssb[i_ssb].active = true; - memcpy((void*)&gNB->ssb[i_ssb].ssb_pdu,&dl_tti_pdu->ssb_pdu,sizeof(dl_tti_pdu->ssb_pdu)); + msgTx->ssb[i_ssb].active = true; + memcpy((void*)&msgTx->ssb[i_ssb].ssb_pdu,&dl_tti_pdu->ssb_pdu,sizeof(dl_tti_pdu->ssb_pdu)); } } @@ -100,46 +101,16 @@ void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, }*/ -void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB, - int frame, int slot, - nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu) { - - LOG_D(PHY,"Frame %d, Slot %d: DCI processing - proc:slot_tx:%d pdcch_pdu_rel15->numDlDci:%d\n",frame,slot, slot, pdcch_pdu->pdcch_pdu_rel15.numDlDci); - - // copy dci configuration into gNB structure - // gNB->pdcch_pdu = pdcch_pdu; - - nr_fill_dci(gNB,frame,slot,pdcch_pdu); - -} - - -void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB, - int frame, int slot, - nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu) { - - LOG_D(PHY,"Frame %d, Slot %d: UL DCI processing - proc:slot_tx:%d pdcch_pdu_rel15->numDlDci:%d\n",frame,slot, slot, ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15.numDlDci); - - // copy dci configuration into gNB structure - // gNB->ul_dci_pdu = ul_dci_request_pdu; - - nr_fill_ul_dci(gNB,frame,slot,ul_dci_request_pdu); - -} - - -void handle_nfapi_nr_csirs_pdu(PHY_VARS_gNB *gNB, - int frame, int slot, +void handle_nfapi_nr_csirs_pdu(processingData_L1tx_t *msgTx, + int frame,int slot, nfapi_nr_dl_tti_csi_rs_pdu *csirs_pdu) { int found = 0; for (int id=0; idcsirs_pdu[id]; + NR_gNB_CSIRS_t *csirs = &msgTx->csirs_pdu[id]; if (csirs->active == 0) { LOG_D(PHY,"Frame %d Slot %d CSI_RS with ID %d is now active\n",frame,slot,id); - csirs->frame = frame; - csirs->slot = slot; csirs->active = 1; memcpy((void*)&csirs->csirs_pdu, (void*)csirs_pdu, sizeof(nfapi_nr_dl_tti_csi_rs_pdu)); found = 1; @@ -151,13 +122,13 @@ void handle_nfapi_nr_csirs_pdu(PHY_VARS_gNB *gNB, } -void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, +void handle_nr_nfapi_pdsch_pdu(processingData_L1tx_t *msgTx, nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint8_t *sdu) { - nr_fill_dlsch(gNB,frame,slot,pdsch_pdu,sdu); + nr_fill_dlsch(msgTx,pdsch_pdu,sdu); } @@ -176,7 +147,11 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n"); AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id); - gNB = RC.gNB[Mod_id]; + gNB = RC.gNB[Mod_id]; + + notifiedFIFO_elt_t *res; + res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); uint8_t number_dl_pdu = (DL_req==NULL) ? 0 : DL_req->dl_tti_request_body.nPDUs; uint8_t number_ul_dci_pdu = (UL_dci_req==NULL) ? 0 : UL_dci_req->numPdus; @@ -184,7 +159,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ uint8_t number_tx_data_pdu = (TX_req == NULL) ? 0 : TX_req->Number_of_PDUs; if (NFAPI_MODE == NFAPI_MONOLITHIC){ - if (DL_req != NULL && TX_req!=NULL) + if (DL_req != NULL && TX_req!=NULL && (number_dl_pdu > 0 || number_ul_dci_pdu > 0 || number_ul_tti_pdu > 0)) LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SLOT:%04d/%d DL_req:SFN/SLO:%04d/%d:dl_pdu:%d tx_req:SFN/SLOT:%04d/%d:pdus:%d;ul_dci %d ul_tti %d\n", frame,slot, DL_req->SFN,DL_req->Slot,number_dl_pdu, @@ -192,33 +167,31 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ number_ul_dci_pdu,number_ul_tti_pdu); int pdcch_received=0; - gNB->num_pdsch_rnti[slot]=0; - for (int i=0; inumber_of_nr_dlsch_max; i++) { - gNB->dlsch[i][0]->rnti=0; - gNB->dlsch[i][0]->harq_mask=0; - } + msgTx->num_pdsch_slot=0; + msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->slot = slot; + msgTx->frame = frame; for (int i=0;idl_tti_request_body.dl_tti_pdu_list[i]; LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType); switch (dl_tti_pdu->PDUType) { case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: - handle_nr_nfapi_ssb_pdu(gNB,frame,slot, + handle_nr_nfapi_ssb_pdu(msgTx,frame,slot, dl_tti_pdu); break; case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: AssertFatal(pdcch_received == 0, "pdcch_received is not 0, we can only handle one PDCCH PDU per slot\n"); - handle_nfapi_nr_pdcch_pdu(gNB, - frame, slot, - &dl_tti_pdu->pdcch_pdu); + msgTx->pdcch_pdu = dl_tti_pdu->pdcch_pdu; + pdcch_received = 1; break; case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); - handle_nfapi_nr_csirs_pdu(gNB, - frame, slot, + handle_nfapi_nr_csirs_pdu(msgTx,frame,slot, &dl_tti_pdu->csi_rs_pdu); break; @@ -229,16 +202,17 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n", pduIndex,TX_req->pdu_list[pduIndex].num_TLV); uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct; - handle_nr_nfapi_pdsch_pdu(gNB,frame,slot,&dl_tti_pdu->pdsch_pdu, sdu); - break; + AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", + msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); + handle_nr_nfapi_pdsch_pdu(msgTx,&dl_tti_pdu->pdsch_pdu, sdu); } } + if (number_ul_dci_pdu > 0) + msgTx->ul_pdcch_pdu = UL_dci_req->ul_dci_pdu_list[number_ul_dci_pdu-1]; // copy the last pdu + + pushNotifiedFIFO(gNB->resp_L1_tx,res); - for (int i=0;iul_dci_pdu_list[i]); - } - for (int i = 0; i < number_ul_tti_pdu; i++) { switch (UL_tti_req->pdus_list[i].pdu_type) { case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE: @@ -266,13 +240,13 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (number_ul_dci_pdu>0) oai_nfapi_ul_dci_req(UL_dci_req); - + if (number_dl_pdu>0) oai_nfapi_dl_tti_req(DL_req); if (number_tx_data_pdu>0) oai_nfapi_tx_data_req(TX_req); - } - + } + } diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 19c98e4ec0..f598b263c3 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -37,13 +37,13 @@ #include "nfapi_nr_interface_scf.h" // added -void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB, +void handle_nr_nfapi_ssb_pdu(processingData_L1tx_t *msgTx, int frame,int slot, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu); void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO); -void handle_nfapi_nr_csirs_pdu(PHY_VARS_gNB *gNB, +void handle_nfapi_nr_csirs_pdu(processingData_L1tx_t *msgTx, int frame, int slot, nfapi_nr_dl_tti_csi_rs_pdu *csirs_pdu); @@ -51,12 +51,12 @@ void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB, int frame, int subframe, nfapi_nr_dl_tti_pdcch_pdu *dcl_dl_pdu); -void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, +void handle_nr_nfapi_pdsch_pdu(processingData_L1tx_t *msgTx, nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint8_t *sdu); -void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid, uint8_t crc_flag); +void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid, uint8_t crc_flag,int dtx_flag); //added void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB, diff --git a/openair1/SCHED_NR/nr_prach_procedures.c b/openair1/SCHED_NR/nr_prach_procedures.c index cc51ce7fe3..1ea8dbdf3c 100644 --- a/openair1/SCHED_NR/nr_prach_procedures.c +++ b/openair1/SCHED_NR/nr_prach_procedures.c @@ -49,6 +49,59 @@ extern uint8_t nfapi_mode; +uint8_t get_nr_prach_duration(uint8_t prach_format){ + + switch(prach_format){ + + case 0: // format 0 + return 0; + + case 1: // format 1 + return 0; + + case 2: // format 2 + return 0; + + case 3: // format 3 + return 0; + + case 4: // format A1 + return 2; + + case 5: // format A2 + return 4; + + case 6: // format A3 + return 6; + + case 7: // format B1 + return 2; + + case 8: // format B4 + return 12; + + case 9: // format C0 + return 2; + + case 10: // format C2 + return 6; + + case 11: // format A1/B1 + return 2; + + case 12: // format A2/B2 + return 4; + + case 13: // format A3/B3 + return 6; + + default : + AssertFatal(1==0,"Invalid Prach format\n"); + break; + + } +} + void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) { uint16_t max_preamble[4]={0},max_preamble_energy[4]={0},max_preamble_delay[4]={0}; @@ -121,7 +174,7 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) { if ((gNB->prach_energy_counter == 100) && (max_preamble_energy[0] > gNB->measurements.prach_I0+gNB->prach_thres)) { - LOG_I(PHY,"[gNB %d][RAPROC] Frame %d, slot %d Initiating RA procedure with preamble %d, energy %d.%d dB (I0 %d, thres %d), delay %d start symbol %u freq index %u\n", + LOG_I(NR_PHY,"[gNB %d][RAPROC] Frame %d, slot %d Initiating RA procedure with preamble %d, energy %d.%d dB (I0 %d, thres %d), delay %d start symbol %u freq index %u\n", gNB->Mod_id, frame, slot, diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index eb0a4f8cdc..d8fa11d157 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -531,12 +531,12 @@ void nr_fep0(RU_t *ru, int first_half) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 1); - // remove_7_5_kHz(ru,(slot&1)+(proc->tti_rx<<1)); + int offset = (proc->tti_rx&3) * fp->symbols_per_slot * fp->ofdm_symbol_size; for (l = start_symbol; l < end_symbol; l++) { for (aa = 0; aa < fp->nb_antennas_rx; aa++) { nr_slot_fep_ul(fp, ru->common.rxdata[aa], - ru->common.rxdataF[aa], + &ru->common.rxdataF[aa][offset], l, proc->tti_rx, ru->N_TA_offset); @@ -665,14 +665,15 @@ void nr_fep_full(RU_t *ru, int slot) { start_meas(&ru->ofdm_demod_stats); if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + // remove_7_5_kHz(ru,proc->tti_rx<<1); // remove_7_5_kHz(ru,1+(proc->tti_rx<<1)); - + int offset = (proc->tti_rx&3)*(fp->symbols_per_slot * fp->ofdm_symbol_size); for (l = 0; l < fp->symbols_per_slot; l++) { for (aa = 0; aa < fp->nb_antennas_rx; aa++) { nr_slot_fep_ul(fp, ru->common.rxdata[aa], - ru->common.rxdataF[aa], + &ru->common.rxdataF[aa][offset], l, proc->tti_rx, ru->N_TA_offset); diff --git a/openair1/SCHED_NR/phy_frame_config_nr.c b/openair1/SCHED_NR/phy_frame_config_nr.c index 9be6780597..25c39846fe 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.c +++ b/openair1/SCHED_NR/phy_frame_config_nr.c @@ -30,6 +30,7 @@ ************************************************************************/ #include "PHY/defs_nr_common.h" +#include "PHY/defs_gNB.h" #include "PHY/defs_nr_UE.h" #include "SCHED_NR/phy_frame_config_nr.h" @@ -308,6 +309,21 @@ int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms) { * *********************************************************************/ +int get_next_downlink_slot(PHY_VARS_gNB *gNB, nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot) { + + int slot = nr_slot; + int frame = nr_frame; + int slots_per_frame = gNB->frame_parms.slots_per_frame; + while (true) { + slot++; + if (slot/slots_per_frame) frame++; + slot %= slots_per_frame; + int slot_type = nr_slot_select(cfg, frame, slot); + if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) return slot; + AssertFatal(frame < (nr_frame+2), "Something went worng. This shouldn't happen\n"); + } +} + int nr_slot_select(nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot) { /* for FFD all slot can be considered as an uplink */ int mu = cfg->ssb_config.scs_common.value,check_slot=0; diff --git a/openair1/SCHED_NR/phy_frame_config_nr.h b/openair1/SCHED_NR/phy_frame_config_nr.h index 434dc41d1f..aba26283ed 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.h +++ b/openair1/SCHED_NR/phy_frame_config_nr.h @@ -92,5 +92,7 @@ void free_tdd_configuration_nr(NR_DL_FRAME_PARMS *frame_parms); void free_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms); +int get_next_downlink_slot(PHY_VARS_gNB *gNB, nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot); + #endif /* PHY_FRAME_CONFIG_NR_H */ diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 0a87a08a56..63cf6f2f2d 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -124,10 +124,12 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ } -void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, - int frame,int slot, +void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, + int frame, + int slot, int do_meas) { int aa; + PHY_VARS_gNB *gNB = msgTx->gNB; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; int offset = gNB->CC_id; @@ -138,7 +140,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,1); - if (do_meas==1) start_meas(&gNB->phy_proc_tx); + if (do_meas==1) start_meas(&msgTx->phy_proc_tx); // clear the transmit data array and beam index for the current slot for (aa=0; aacarrier_config.num_tx_ant.value; aa++) { @@ -147,58 +149,44 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_COMMON_TX,1); - for (int i=0; iLmax; i++) { - if (gNB->ssb[i].active) { - nr_common_signal_procedures(gNB,frame,slot,gNB->ssb[i].ssb_pdu); - gNB->ssb[i].active = false; + if (msgTx->ssb[i].active) { + nr_common_signal_procedures(gNB,frame,slot,msgTx->ssb[i].ssb_pdu); + msgTx->ssb[i].active = false; } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_COMMON_TX,0); - int pdcch_pdu_id=find_nr_pdcch(frame,slot,gNB,SEARCH_EXIST); - int ul_pdcch_pdu_id=find_nr_ul_dci(frame,slot,gNB,SEARCH_EXIST); + int num_dl_dci = msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci; + int num_ul_dci = msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci; - LOG_D(PHY,"[gNB %d] Frame %d slot %d, pdcch_pdu_id %d, ul_pdcch_pdu_id %d\n", - gNB->Mod_id,frame,slot,pdcch_pdu_id,ul_pdcch_pdu_id); - - if (pdcch_pdu_id >= 0 || ul_pdcch_pdu_id >= 0) { + if (num_dl_dci > 0 || num_ul_dci > 0) { LOG_D(PHY, "[gNB %d] Frame %d slot %d Calling nr_generate_dci_top (number of UL/DL DCI %d/%d)\n", - gNB->Mod_id, frame, slot, - gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci, - gNB->pdcch_pdu[pdcch_pdu_id].pdcch_pdu.pdcch_pdu_rel15.numDlDci); + gNB->Mod_id, frame, slot, num_ul_dci, num_dl_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,1); nr_generate_dci_top(gNB, - pdcch_pdu_id>=0 ? &gNB->pdcch_pdu[pdcch_pdu_id].pdcch_pdu : NULL, - ul_pdcch_pdu_id>=0 ? &gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].pdcch_pdu.pdcch_pdu : NULL, + num_dl_dci > 0 ? &msgTx->pdcch_pdu : NULL, + num_ul_dci > 0 ? &msgTx->ul_pdcch_pdu.pdcch_pdu : NULL, gNB->nr_gold_pdcch_dmrs[slot], &gNB->common_vars.txdataF[0][txdataF_offset], AMP, fp); - // free up entry in pdcch tables - if (pdcch_pdu_id>=0) gNB->pdcch_pdu[pdcch_pdu_id].frame = -1; - if (ul_pdcch_pdu_id>=0) gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].frame = -1; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,0); - if (pdcch_pdu_id >= 0) gNB->pdcch_pdu[pdcch_pdu_id].frame = -1; - if (ul_pdcch_pdu_id >= 0) gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].frame = -1; } - for (int i=0; inum_pdsch_rnti[slot]; i++) { + if (msgTx->num_pdsch_slot > 0) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1); - LOG_D(PHY, "PDSCH generation started (%d) in frame %d.%d\n", gNB->num_pdsch_rnti[slot],frame,slot); - nr_generate_pdsch(gNB,frame, slot); + LOG_D(PHY, "PDSCH generation started (%d) in frame %d.%d\n", msgTx->num_pdsch_slot,frame,slot); + nr_generate_pdsch(msgTx, frame, slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0); } for (int i=0;icsirs_pdu[i]; - if ((csirs->active == 1) && - (csirs->frame == frame) && - (csirs->slot == slot) ) { + NR_gNB_CSIRS_t *csirs = &msgTx->csirs_pdu[i]; + if ((csirs->active == 1)) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; nr_generate_csi_rs(gNB, AMP, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); @@ -206,9 +194,9 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, } } - if (do_meas==1) stop_meas(&gNB->phy_proc_tx); + if (do_meas==1) stop_meas(&msgTx->phy_proc_tx); - if ((frame&127) == 0) dump_pdsch_stats(gNB); +// if ((frame&127) == 0) dump_pdsch_stats(gNB); //apply the OFDM symbol rotation here for (aa=0; aacarrier_config.num_tx_ant.value; aa++) { @@ -234,6 +222,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; NR_gNB_ULSCH_t *ulsch = rdata->ulsch; int r = rdata->segment_r; + nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[rdata->ulsch_id][0]->harq_processes[rdata->harq_pid]->ulsch_pdu; bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter); ulsch_harq->processedSegments++; @@ -260,21 +249,30 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } } - // if all segments are done + //int dumpsig=0; + // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { - LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", - gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS); + LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for SFN/SF %d.%d (pid %d, ndi %d, status %d, round %d, TBS %d, Max interation (all seg) %d)\n", + gNB->Mod_id,ulsch_harq->frame,ulsch_harq->slot,rdata->harq_pid,pusch_pdu->pusch_data.new_data_indicator,ulsch_harq->status,ulsch_harq->round,ulsch_harq->TBS,rdata->decodeIterations); ulsch_harq->status = SCH_IDLE; ulsch_harq->round = 0; ulsch->harq_mask &= ~(1 << rdata->harq_pid); LOG_D(PHY, "ULSCH received ok \n"); - nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); + nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0,0); + //dumpsig=1; } else { - LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", + LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, - rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); + rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator, ulsch_harq->status, + ulsch_harq->round, + ulsch_harq->ulsch_pdu.pusch_data.rv_index, + ulsch_harq->ulsch_pdu.rb_start, + ulsch_harq->ulsch_pdu.rb_size, + ulsch_harq->TBS, + r); + ulsch_harq->round++; if (ulsch_harq->round >= ulsch->Mlimit) { ulsch_harq->status = SCH_IDLE; ulsch_harq->round = 0; @@ -284,8 +282,42 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ulsch_harq->handled = 1; LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); - nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1); + nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1,0); } +/* + if (ulsch_harq->ulsch_pdu.mcs_index == 9 && dumpsig==1) { +#ifdef __AVX2__ + int off = ((ulsch_harq->ulsch_pdu.rb_size&1) == 1)? 4:0; +#else + int off = 0; +#endif + + LOG_M("rxsigF0_ext.m","rxsF0_ext", + &gNB->pusch_vars[0]->rxdataF_ext[0][ulsch_harq->ulsch_pdu.start_symbol_index*NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size],ulsch_harq->ulsch_pdu.nr_of_symbols*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + LOG_M("chestF0.m","chF0", + &gNB->pusch_vars[0]->ul_ch_estimates[0][ulsch_harq->ulsch_pdu.start_symbol_index*gNB->frame_parms.ofdm_symbol_size],gNB->frame_parms.ofdm_symbol_size,1,1); + LOG_M("chestF0_ext.m","chF0_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(ulsch_harq->ulsch_pdu.start_symbol_index+1)*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size))], + (ulsch_harq->ulsch_pdu.nr_of_symbols-1)*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + LOG_M("rxsigF0_comp.m","rxsF0_comp", + &gNB->pusch_vars[0]->rxdataF_comp[0][ulsch_harq->ulsch_pdu.start_symbol_index*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size))],ulsch_harq->ulsch_pdu.nr_of_symbols*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + LOG_M("rxsigF0_llr.m","rxsF0_llr", + &gNB->pusch_vars[0]->llr[0],(ulsch_harq->ulsch_pdu.nr_of_symbols-1)*NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size * ulsch_harq->ulsch_pdu.qam_mod_order,1,0); + if (gNB->frame_parms.nb_antennas_rx > 1) { + + LOG_M("rxsigF1_ext.m","rxsF0_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][ulsch_harq->ulsch_pdu.start_symbol_index*NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size],ulsch_harq->ulsch_pdu.nr_of_symbols*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + LOG_M("chestF1.m","chF1", + &gNB->pusch_vars[0]->ul_ch_estimates[1][ulsch_harq->ulsch_pdu.start_symbol_index*gNB->frame_parms.ofdm_symbol_size],gNB->frame_parms.ofdm_symbol_size,1,1); + LOG_M("chestF1_ext.m","chF1_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(ulsch_harq->ulsch_pdu.start_symbol_index+1)*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size))], + (ulsch_harq->ulsch_pdu.nr_of_symbols-1)*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + LOG_M("rxsigF1_comp.m","rxsF1_comp", + &gNB->pusch_vars[0]->rxdataF_comp[1][ulsch_harq->ulsch_pdu.start_symbol_index*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size))],ulsch_harq->ulsch_pdu.nr_of_symbols*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); + } + exit(-1); + + } */ ulsch->last_iteration_cnt = rdata->decodeIterations; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0); } @@ -367,7 +399,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH } - void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid, uint8_t crc_flag) { +void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid, uint8_t crc_flag, int dtx_flag) { pthread_mutex_lock(&gNB->UL_INFO_mutex); @@ -375,6 +407,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH int sync_pos; NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; + NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch); nfapi_nr_pusch_pdu_t *pusch_pdu = &harq_process->ulsch_pdu; @@ -389,6 +422,8 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH sync_pos_rounded = sync_pos + (bw_scaling / 2) - 1; else sync_pos_rounded = sync_pos - (bw_scaling / 2) - 1; + if (stats) stats->sync_pos = sync_pos; + timing_advance_update = sync_pos_rounded / bw_scaling; // put timing advance command in 0..63 range @@ -397,8 +432,16 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH if (timing_advance_update < 0) timing_advance_update = 0; if (timing_advance_update > 63) timing_advance_update = 63; - LOG_D(PHY, "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", sync_pos,timing_advance_update); - + if (crc_flag == 0) LOG_D(PHY, "%d.%d : Received PUSCH : Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", frame,slot_rx,sync_pos,timing_advance_update); + else if (harq_process->round>0 || dtx_flag == 0) { // increment round if crc_flag == 1 and not(dtx_flag ==1 and round==0) + harq_process->round++; + if (harq_process->round >= ulsch->Mlimit) { + harq_process->status = SCH_IDLE; + harq_process->round = 0; + harq_process->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + } + } // estimate UL_CQI for MAC int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) - @@ -410,6 +453,41 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH else if (SNRtimes10 > 635) cqi=255; else cqi=(640+SNRtimes10)/5; + + if (0/*pusch_pdu->mcs_index == 9*/) { +#ifdef __AVX2__ + int off = ((pusch_pdu->rb_size&1) == 1)? 4:0; +#else + int off = 0; +#endif + LOG_M("rxsigF0.m","rxsF0",&gNB->common_vars.rxdataF[0][(slot_rx&3)*gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot],gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot,1,1); + LOG_M("rxsigF0_ext.m","rxsF0_ext", + &gNB->pusch_vars[0]->rxdataF_ext[0][pusch_pdu->start_symbol_index*NR_NB_SC_PER_RB * pusch_pdu->rb_size],pusch_pdu->nr_of_symbols*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF0.m","chF0", + &gNB->pusch_vars[0]->ul_ch_estimates[0][pusch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size],gNB->frame_parms.ofdm_symbol_size,1,1); + LOG_M("chestF0_ext.m","chF0_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(pusch_pdu->start_symbol_index+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (pusch_pdu->nr_of_symbols-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF0_comp.m","rxsF0_comp", + &gNB->pusch_vars[0]->rxdataF_comp[0][pusch_pdu->start_symbol_index*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],pusch_pdu->nr_of_symbols*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF0_llr.m","rxsF0_llr", + &gNB->pusch_vars[0]->llr[0],(pusch_pdu->nr_of_symbols-1)*NR_NB_SC_PER_RB *pusch_pdu->rb_size * pusch_pdu->qam_mod_order,1,0); + if (gNB->frame_parms.nb_antennas_rx > 1) { + LOG_M("rxsigF1.m","rxsF1",&gNB->common_vars.rxdataF[1][(slot_rx&3)*gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot],gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot,1,1); + LOG_M("rxsigF1_ext.m","rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][pusch_pdu->start_symbol_index*NR_NB_SC_PER_RB * pusch_pdu->rb_size],pusch_pdu->nr_of_symbols*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF1.m","chF1", + &gNB->pusch_vars[0]->ul_ch_estimates[1][pusch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size],gNB->frame_parms.ofdm_symbol_size,1,1); + LOG_M("chestF1_ext.m","chF1_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(pusch_pdu->start_symbol_index+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (pusch_pdu->nr_of_symbols-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF1_comp.m","rxsF1_comp", + &gNB->pusch_vars[0]->rxdataF_comp[1][pusch_pdu->start_symbol_index*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],pusch_pdu->nr_of_symbols*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + } + exit(-1); + + } + // crc indication uint16_t num_crc = gNB->UL_INFO.crc_ind.number_crcs; gNB->UL_INFO.crc_ind.crc_list = &gNB->crc_pdu_list[0]; @@ -424,7 +502,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH gNB->crc_pdu_list[num_crc].ul_cqi = cqi; gNB->crc_pdu_list[num_crc].timing_advance = timing_advance_update; // in terms of dBFS range -128 to 0 with 0.1 step - gNB->crc_pdu_list[num_crc].rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0])); + gNB->crc_pdu_list[num_crc].rssi = (dtx_flag==0) ? 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0])) : 0; gNB->UL_INFO.crc_ind.number_crcs++; @@ -438,7 +516,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH gNB->rx_pdu_list[num_rx].harq_id = harq_pid; gNB->rx_pdu_list[num_rx].ul_cqi = cqi; gNB->rx_pdu_list[num_rx].timing_advance = timing_advance_update; - gNB->rx_pdu_list[num_rx].rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0])); + gNB->rx_pdu_list[num_rx].rssi = gNB->crc_pdu_list[num_crc].rssi; if (crc_flag) gNB->rx_pdu_list[num_rx].pdu_length = 0; else { @@ -454,66 +532,74 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH // Function to fill UL RB mask to be used for N0 measurements void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { - int rb2, rb, nb_rb; + int rb = 0; + int rb2 = 0; + int prbpos = 0; + for (int symbol=0;symbol<14;symbol++) { - if (gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1){ - nb_rb = 0; - for (int m=0;m<9;m++) gNB->rb_mask_ul[m] = 0; - gNB->ulmask_symb = -1; - - for (int i=0;ipucch[i]; - if (pucch) { - if ((pucch->active == 1) && - (pucch->frame == frame_rx) && - (pucch->slot == slot_rx) ) { - gNB->ulmask_symb = symbol; - nfapi_nr_pucch_pdu_t *pucch_pdu = &pucch->pucch_pdu; - if ((symbol>=pucch_pdu->start_symbol_index) && - (symbol<(pucch_pdu->start_symbol_index + pucch_pdu->nr_of_symbols))){ - for (rb=0; rbprb_size; rb++) { - rb2 = rb+pucch_pdu->prb_start+pucch_pdu->bwp_start; - gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); - } - nb_rb+=pucch_pdu->prb_size; - } - } - } + for (int m=0;m<9;m++) { + gNB->rb_mask_ul[symbol][m] = 0; + for (int i=0;i<32;i++) { + prbpos = (m*32)+i; + if (prbpos>gNB->frame_parms.N_RB_UL) break; + gNB->rb_mask_ul[symbol][m] |= (gNB->ulprbbl[prbpos]>0 ? 1 : 0)<number_of_nr_ulsch_max;ULSCH_id++) { - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; - int harq_pid; - NR_UL_gNB_HARQ_t *ulsch_harq; - - if ((ulsch) && - (ulsch->rnti > 0)) { - for (harq_pid=0;harq_pidharq_processes[harq_pid]; - AssertFatal(ulsch_harq!=NULL,"harq_pid %d is not allocated\n",harq_pid); - if ((ulsch_harq->status == NR_ACTIVE) && - (ulsch_harq->frame == frame_rx) && - (ulsch_harq->slot == slot_rx) && - (ulsch_harq->handled == 0)){ - uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; - uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; - gNB->ulmask_symb = symbol; - if ((symbol>=symbol_start) && - (symbolulsch_pdu.rb_size; rb++) { - rb2 = rb+ulsch_harq->ulsch_pdu.rb_start+ulsch_harq->ulsch_pdu.bwp_start; - gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); - } - nb_rb+=ulsch_harq->ulsch_pdu.rb_size; - } - } - } - } - //TODO Add check for PRACH as well? - } - if (nb_rbframe_parms.N_RB_UL) - return; } } + + for (int i=0;ipucch[i]; + if (pucch) { + if ((pucch->active == 1) && + (pucch->frame == frame_rx) && + (pucch->slot == slot_rx) ) { + nfapi_nr_pucch_pdu_t *pucch_pdu = &pucch->pucch_pdu; + LOG_D(PHY,"%d.%d pucch %d : start_symbol %d, nb_symbols %d, prb_size %d\n",frame_rx,slot_rx,i,pucch_pdu->start_symbol_index,pucch_pdu->nr_of_symbols,pucch_pdu->prb_size); + for (int symbol=pucch_pdu->start_symbol_index ; symbol<(pucch_pdu->start_symbol_index+pucch_pdu->nr_of_symbols);symbol++) { + if(gNB->frame_parms.frame_type == FDD || + (gNB->frame_parms.frame_type == TDD && gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1)) { + for (rb=0; rbprb_size; rb++) { + rb2 = rb + pucch_pdu->bwp_start + + ((symbol < pucch_pdu->start_symbol_index+(pucch_pdu->nr_of_symbols>>1)) || (pucch_pdu->freq_hop_flag == 0) ? + pucch_pdu->prb_start : pucch_pdu->second_hop_prb); + gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31)); + } + } + } + } + } + } + + for (int ULSCH_id=0;ULSCH_idnumber_of_nr_ulsch_max;ULSCH_id++) { + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; + int harq_pid; + NR_UL_gNB_HARQ_t *ulsch_harq; + if ((ulsch) && + (ulsch->rnti > 0)) { + for (harq_pid=0;harq_pidharq_processes[harq_pid]; + AssertFatal(ulsch_harq!=NULL,"harq_pid %d is not allocated\n",harq_pid); + if ((ulsch_harq->status == NR_ACTIVE) && + (ulsch_harq->frame == frame_rx) && + (ulsch_harq->slot == slot_rx) && + (ulsch_harq->handled == 0)){ + uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; + uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; + for (int symbol=symbol_start ; symbolframe_parms.frame_type == FDD || + (gNB->frame_parms.frame_type == TDD && gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1)) { + LOG_D(PHY,"symbol %d Filling rb_mask_ul rb_size %d\n",symbol,ulsch_harq->ulsch_pdu.rb_size); + for (rb=0; rbulsch_pdu.rb_size; rb++) { + rb2 = rb+ulsch_harq->ulsch_pdu.rb_start+ulsch_harq->ulsch_pdu.bwp_start; + gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31)); + } + } + } + } + } + } + } + } void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { @@ -551,8 +637,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_UESPEC_RX,1); LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx); - if (gNB->frame_parms.frame_type == TDD) - fill_ul_rb_mask(gNB, frame_rx, slot_rx); + fill_ul_rb_mask(gNB, frame_rx, slot_rx); int first_symb=0,num_symb=0; if (gNB->frame_parms.frame_type == TDD) @@ -563,7 +648,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } } else num_symb=NR_NUMBER_OF_SYMBOLS_PER_SLOT; - gNB_I0_measurements(gNB,first_symb,num_symb); + gNB_I0_measurements(gNB,slot_rx,first_symb,num_symb); int offset = 10*gNB->frame_parms.ofdm_symbol_size + gNB->frame_parms.first_carrier_offset; int power_rxF = signal_energy_nodc(&gNB->common_vars.rxdataF[0][offset+(47*12)],12*18); @@ -683,7 +768,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { no_sig = nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, harq_pid); if (no_sig) { LOG_D(PHY, "PUSCH not detected in frame %d, slot %d\n", frame_rx, slot_rx); - nr_fill_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid, 1); + nr_fill_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid, 1,1); return 1; } gNB->pusch_vars[ULSCH_id]->ulsch_power_tot=0; @@ -702,7 +787,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot), dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot),gNB->pusch_thres); gNB->pusch_vars[ULSCH_id]->ulsch_power_tot = gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot; - nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1); + nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1,1); gNB->pusch_vars[ULSCH_id]->DTX=1; if (stats) stats->DTX++; return 1; @@ -723,7 +808,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { stop_meas(&gNB->phy_proc_rx); // figure out a better way to choose slot_rx, 19 is ok for a particular TDD configuration with 30kHz SCS if ((frame_rx&127) == 0 && slot_rx==19) { - LOG_I(PHY, "Number of bad PUCCH received: %lu\n", gNB->bad_pucch); + LOG_I(NR_PHY, "Number of bad PUCCH received: %lu\n", gNB->bad_pucch); } if (pucch_decode_done || pusch_decode_done) { diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 5e31c08d38..d7e0332b85 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -36,7 +36,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp); -void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx, int slot_tx, int do_meas); +void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, int frame_tx, int slot_tx, int do_meas); void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot); diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 5bde9502dc..b3527365a5 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -340,8 +340,6 @@ uint16_t nr_get_n1_pucch(PHY_VARS_NR_UE *phy_vars_ue, */ UE_MODE_t get_nrUE_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t gNB_index); -uint8_t get_ra_PreambleIndex(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_id); - /*! \brief This function implements the power control mechanism for PUCCH from 36.213. @param phy_vars_ue PHY variables @param proc Pointer to proc descriptor diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 63935124a6..c9d8222e4c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -52,7 +52,8 @@ #endif #include "executables/softmodem-common.h" #include "executables/nr-uesoftmodem.h" -#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" //#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED @@ -64,8 +65,6 @@ #define PUCCH #endif -#include "LAYER2/NR_MAC_UE/mac_defs.h" -#include "LAYER2/NR_MAC_UE/mac_proto.h" #include "common/utils/LOG/log.h" #ifdef EMOS @@ -226,12 +225,6 @@ UE_MODE_t get_nrUE_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t gNB_id){ return(PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[gNB_id]); } -uint8_t get_ra_PreambleIndex(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_id){ - - return PHY_vars_UE_g[Mod_id][CC_id]->prach_resources[gNB_id]->ra_PreambleIndex; - -} - // convert time factor "16 * 64 * T_c / (2^mu)" in N_TA calculation in TS38.213 section 4.2 to samples by multiplying with samples per second // 16 * 64 * T_c / (2^mu) * samples_per_second // = 16 * T_s / (2^mu) * samples_per_second @@ -263,7 +256,7 @@ void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx){ ue->timing_advance += (ul_time_alignment->ta_command - 31) * bw_scaling; - LOG_I(PHY, "In %s: [UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n", + LOG_D(PHY, "In %s: [UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n", __FUNCTION__, ue->Mod_id, frame_tx, @@ -293,9 +286,8 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); -#if UE_TIMING_TRACE + start_meas(&ue->phy_proc_tx); -#endif if (ue->UE_mode[gNB_id] <= PUSCH){ @@ -307,9 +299,8 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE stop_meas(&ue->phy_proc_tx); -#endif + } @@ -491,8 +482,8 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb #ifdef NR_PDCCH_SCHED int nr_ue_pdcch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, int n_ss) { int frame_rx = proc->frame_rx; @@ -658,9 +649,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_IN); -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_rx_pdcch_stats); -#endif + start_meas(&ue->dlsch_rx_pdcch_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); #ifdef NR_PDCCH_SCHED_DEBUG @@ -760,9 +749,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, // send to mac ue->if_inst->dl_indication(&dl_indication, NULL); -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_rx_pdcch_stats); -#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); return(dci_cnt); @@ -844,12 +831,10 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ else first_symbol_flag = 0; -#if UE_TIMING_TRACE uint8_t slot = 0; if(m >= ue->frame_parms.symbols_per_slot>>1) slot = 1; start_meas(&ue->dlsch_llr_stats_parallelization[proc->thread_id][slot]); -#endif // process DLSCH received symbols in the slot // symbol by symbol processing (if data/DMRS are multiplexed is checked inside the function) if (pdsch == PDSCH || pdsch == SI_PDSCH || pdsch == RA_PDSCH) { @@ -868,13 +853,11 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ return -1; } else AssertFatal(1==0,"Not RA_PDSCH, SI_PDSCH or PDSCH\n"); -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_llr_stats_parallelization[proc->thread_id][slot]); -#if DISABLE_LOG_X +#if PHYSIM printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0)); #else LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif #endif if(first_symbol_flag) { @@ -982,19 +965,17 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, dmrs_len, dlsch0->harq_processes[harq_pid]->Qm, dlsch0->harq_processes[harq_pid]->Nl); -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_unscrambling_stats); -#endif - nr_dlsch_unscrambling(pdsch_vars->llr[0], - dlsch0->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch0->rnti); + + start_meas(&ue->dlsch_unscrambling_stats); + nr_dlsch_unscrambling(pdsch_vars->llr[0], + dlsch0->harq_processes[harq_pid]->G, + 0, + ue->frame_parms.Nid_cell, + dlsch0->rnti); -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_unscrambling_stats); -#endif + stop_meas(&ue->dlsch_unscrambling_stats); + #if 0 LOG_I(PHY," ------ start ldpc decoder for AbsSubframe %d.%d / %d ------ \n", frame_rx, nr_slot_rx, harq_pid); @@ -1007,9 +988,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, nr_slot_rx, harq_pid, ue->pdcch_vars[proc->thread_id][gNB_id]->num_pdcch_symbols); #endif -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_decoding_stats[proc->thread_id]); -#endif + + start_meas(&ue->dlsch_decoding_stats[proc->thread_id]); if( dlsch_parallel) { ret = nr_dlsch_decoding_mthread(ue, @@ -1070,9 +1050,9 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); -#if DISABLE_LOG_X + + stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); +#if PHYSIM printf(" --> Unscrambling for CW0 %5.3f\n", (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); printf("AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", @@ -1084,7 +1064,6 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); #endif -#endif if(is_cw1_active) { // start ldpc decode for CW 1 dlsch1->harq_processes[harq_pid]->G = nr_get_G(dlsch1->harq_processes[harq_pid]->nb_rb, @@ -1093,17 +1072,13 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, dmrs_len, dlsch1->harq_processes[harq_pid]->Qm, dlsch1->harq_processes[harq_pid]->Nl); -#if UE_TIMING_TRACE start_meas(&ue->dlsch_unscrambling_stats); -#endif nr_dlsch_unscrambling(pdsch_vars->llr[1], dlsch1->harq_processes[harq_pid]->G, 0, ue->frame_parms.Nid_cell, dlsch1->rnti); -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_unscrambling_stats); -#endif #if 0 LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->nb_rb); @@ -1115,9 +1090,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, nr_slot_rx, harq_pid, ue->pdcch_vars[proc->thread_id][gNB_id]->num_pdcch_symbols); #endif -#if UE_TIMING_TRACE start_meas(&ue->dlsch_decoding_stats[proc->thread_id]); -#endif + if(dlsch_parallel) { ret1 = nr_dlsch_decoding_mthread(ue, @@ -1152,9 +1126,9 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_T(PHY,"CWW sequential dlsch decoding, ret1 = %d\n", ret1); } -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); -#if DISABLE_LOG_X + + stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); +#if PHYSIM printf(" --> Unscrambling for CW1 %5.3f\n", (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); printf("AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", @@ -1166,7 +1140,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); #endif -#endif + LOG_D(PHY,"AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); @@ -1383,9 +1357,9 @@ void *UE_thread_slot1_dl_processing(void *arg) { } /**** Slot1 FE Processing ****/ -#if UE_TIMING_TRACE + start_meas(&ue->ue_front_end_per_slot_stat[proc->thread_id][1]); -#endif + // I- start dl slot1 processing // do first symbol of next downlink nr_slot_rx for channel estimation /* @@ -1410,9 +1384,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { { //if( (l != pilot0) && (l != pilot1)) { -#if UE_TIMING_TRACE + start_meas(&ue->ofdm_demod_stats); -#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,nr_slot_rx,slot1,l); front_end_fft(ue, @@ -1421,9 +1394,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { 0, 0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE stop_meas(&ue->ofdm_demod_stats); -#endif } } // for l=1..l2 @@ -1476,14 +1447,13 @@ void *UE_thread_slot1_dl_processing(void *arg) { //printf(" [slot1 dl processing] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->nr_slot_rx); -#if UE_TIMING_TRACE + stop_meas(&ue->ue_front_end_per_slot_stat[proc->thread_id][1]); -#if DISABLE_LOG_X +#if PHYSIM printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); #else LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); #endif -#endif //wait until pdcch is decoded @@ -1501,9 +1471,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { //printf("AbsSubframe %d.%d Pdsch Procedure (slot1)\n",frame_rx,nr_slot_rx); -#if UE_TIMING_TRACE start_meas(&ue->pdsch_procedures_per_slot_stat[proc->thread_id][1]); -#endif + // start slave thread for Pdsch Procedure (slot1) // do procedures for C-RNTI uint8_t gNB_id = 0; @@ -1573,13 +1542,11 @@ void *UE_thread_slot1_dl_processing(void *arg) { proc->llr_slot1_available=1; //printf("Set available LLR slot1 to 1 AbsSubframe %d.%d \n",frame_rx,nr_slot_rx); -#if UE_TIMING_TRACE stop_meas(&ue->pdsch_procedures_per_slot_stat[proc->thread_id][1]); -#if DISABLE_LOG_X +#if PHYSIM printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); #else LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); -#endif #endif if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { @@ -1693,7 +1660,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); - LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_slot_rx); + LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d (energy %d dB)****** \n", + frame_rx%1024, nr_slot_rx, + dB_fixed(signal_energy(ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0],2048*14))); /* uint8_t next1_thread_id = proc->thread_id== (RX_NB_TH-1) ? 0:(proc->thread_id+1); @@ -1720,13 +1689,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, (ue->symbol_offset+i)%(fp->symbols_per_slot), nr_slot_rx); -#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); -#endif nr_pbch_channel_estimation(ue,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); -#endif } nr_ue_rsrp_measurements(ue, gNB_id, proc, nr_slot_rx, 0); @@ -1754,9 +1720,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } if ((frame_rx%64 == 0) && (nr_slot_rx==0)) { - LOG_I(PHY,"============================================\n"); - LOG_I(PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[4]); - LOG_I(PHY,"============================================\n"); + LOG_I(NR_PHY,"============================================\n"); + LOG_I(NR_PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[4]); + LOG_I(NR_PHY,"============================================\n"); } #ifdef NR_PDCCH_SCHED @@ -1766,9 +1732,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, for (uint16_t l=0; lofdm_demod_stats); -#endif nr_slot_fep(ue, proc, l, @@ -1792,9 +1756,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, coreset_nb_rb); -#if UE_TIMING_TRACE stop_meas(&ue->ofdm_demod_stats); -#endif + } dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, n_ss); } @@ -1844,10 +1807,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, curMsg->UE = ue; curMsg->ue_sched_mode = ONLY_PUSCH; pushTpool(&(get_nrUE_params()->Tpool), newElt); - -#if UE_TIMING_TRACE start_meas(&ue->generic_stat); -#endif // do procedures for C-RNTI int ret_pdsch = 0; if (ue->dlsch[proc->thread_id][gNB_id][0]->active == 1) { @@ -1944,9 +1904,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d \n \n", nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); -#if UE_TIMING_TRACE start_meas(&ue->dlsch_procedures_stat[proc->thread_id]); -#endif if (ret_pdsch >= 0) nr_ue_dlsch_procedures(ue, @@ -1958,10 +1916,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, &ue->dlsch_errors[gNB_id], dlsch_parallel); - -#if UE_TIMING_TRACE stop_meas(&ue->dlsch_procedures_stat[proc->thread_id]); -#if DISABLE_LOG_X +#if PHYSIM printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); #else @@ -1969,7 +1925,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); #endif -#endif + // deactivate dlsch once dlsch proc is done ue->dlsch[proc->thread_id][gNB_id][0]->active = 0; @@ -1978,9 +1934,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } -#if UE_TIMING_TRACE start_meas(&ue->generic_stat); -#endif #if 0 @@ -2045,8 +1999,8 @@ if (nr_slot_rx==9) { } -#if UE_TIMING_TRACE stop_meas(&ue->generic_stat); +#if PHYSIM printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); #endif @@ -2057,14 +2011,12 @@ phy_procedures_emos_UE_RX(ue,slot,gNB_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE stop_meas(&ue->phy_proc_rx[proc->thread_id]); -#if DISABLE_LOG_X +#if PHYSIM printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0)); #else LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0)); #endif -#endif //#endif //pdsch diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 2dbe6dcb9a..77ac105e14 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -38,7 +38,6 @@ #include "PHY/defs_nr_UE.h" #include #include -#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" #include "openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h" #include #include @@ -58,115 +57,6 @@ uint8_t nr_is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); uint8_t nr_is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); -/* TS 36.213 Table 9.2.5.2-1: Code rate corresponding to higher layer parameter PUCCH-F2-maximum-coderate, */ -/* or PUCCH-F3-maximum-coderate, or PUCCH-F4-maximum-coderate */ -/* add one additional element set to 0 for parsing the array until this end */ -/* stored values are code rates * 100 */ -//static const int code_rate_r_time_100[8] = { (0.08 * 100), (0.15 * 100), (0.25*100), (0.35*100), (0.45*100), (0.60*100), (0.80*100), 0 } ; - -static float RSRP_meas_mapping_nr[98] -= { - -140, - -139, - -138, - -137, - -136, - -135, - -134, - -133, - -132, - -131, - -130, - -129, - -128, - -127, - -126, - -125, - -124, - -123, - -122, - -121, - -120, - -119, - -118, - -117, - -116, - -115, - -114, - -113, - -112, - -111, - -110, - -109, - -108, - -107, - -106, - -105, - -104, - -103, - -102, - -101, - -100, - -99, - -98, - -97, - -96, - -95, - -94, - -93, - -92, - -91, - -90, - -89, - -88, - -87, - -86, - -85, - -84, - -83, - -82, - -81, - -80, - -79, - -78, - -77, - -76, - -75, - -74, - -73, - -72, - -71, - -70, - -69, - -68, - -67, - -66, - -65, - -64, - -63, - -62, - -61, - -60, - -59, - -58, - -57, - -56, - -55, - -54, - -53, - -52, - -51, - -50, - -49, - -48, - -47, - -46, - -45, - -44, - -43 - } - ; - long binary_search_float_nr( float elements[], @@ -341,12 +231,14 @@ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, int tx_amp; + /* tx_amp = nr_get_tx_amp(pucch_tx_power, ue->tx_power_max_dBm, ue->frame_parms.N_RB_UL, nb_of_prbs); - if (tx_amp == 0) - tx_amp = AMP; + if (tx_amp == 0)*/ + // FIXME temporarly using fixed amplitude before pucch power control implementation revised + tx_amp = AMP; LOG_D(PHY,"Generation of PUCCH format %d at frame.slot %d.%d\n",pucch_pdu->format_type,proc->frame_tx,nr_slot_tx); @@ -392,187 +284,10 @@ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, } -/******************************************************************* -* -* NAME : check_pucch_format -* -* PARAMETERS : ue context -* processing slots of reception/transmission -* gNB_id identifier -* -* RETURN : harq process identifier -* -* DESCRIPTION : return tx harq process identifier for given transmission slot -* YS 38.213 9.2.2 PUCCH Formats for UCI transmission -* -*********************************************************************/ - -boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, int uci_size) -{ - pucch_format_nr_t selected_pucch_format; - pucch_format_nr_t selected_pucch_format_second; - /*NR_SetupRelease_PUCCH_FormatConfig_t *identified_format = NULL; - - switch (format_pucch) { - case pucch_format1_nr: - if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1 != NULL) - identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1; - break; - - case pucch_format2_nr: - if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2 != NULL) - identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2; - break; - - case pucch_format3_nr: - if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3 != NULL) - identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3; - break; - - case pucch_format4_nr: - if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4 != NULL) - identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4; - break; - - default: - break; - }*/ - - /* if ((identified_format != NULL) && (identified_format->choice.setup->nrofSlots[0] != 1)) { - LOG_E(PHY,"PUCCH not implemented multislots transmission : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (FALSE); - }*/ - - if (nb_symbols_for_tx <= 2) { - if (uci_size <= 2) { - selected_pucch_format = pucch_format0_nr; - selected_pucch_format_second = selected_pucch_format; - } - else { - selected_pucch_format = pucch_format2_nr; - selected_pucch_format_second = selected_pucch_format; - } - } - else { - if (nb_symbols_for_tx >= 4) { - if (uci_size <= 2) { - selected_pucch_format = pucch_format1_nr; - selected_pucch_format_second = selected_pucch_format; - } - else { - selected_pucch_format = pucch_format3_nr; /* in this case choice can be done between two formats */ - selected_pucch_format_second = pucch_format4_nr; - } - } - else { - LOG_D(PHY,"PUCCH Undefined PUCCH format : set PUCCH to format 4 : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (FALSE); - } - } - - NR_TST_PHY_PRINTF("PUCCH format %d nb symbols total %d uci size %d selected format %d \n", format_pucch, nb_symbols_for_tx, uci_size, selected_pucch_format); - - if (format_pucch != selected_pucch_format) { - if (format_pucch != selected_pucch_format_second) { - NR_TST_PHY_PRINTF("PUCCH mismatched of selected format: at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - LOG_D(PHY,"PUCCH format mismatched of selected format: at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (FALSE); - } - else { - return (TRUE); - } - } - else { - return (TRUE); - } -} - - - -/******************************************************************* -* -* NAME : get_csi_nr -* PARAMETERS : ue context -* processing slots of reception/transmission -* gNB_id identifier -* -* RETURN : size of csi payload -* -* DESCRIPTION : CSI management is not already implemented -* so it has been simulated thank to two functions: -* - set_csi_nr -* - get_csi_nr -* -*********************************************************************/ int dummy_csi_status = 0; uint32_t dummy_csi_payload = 0; -/* FFS TODO_NR code that should be developed */ - -uint16_t get_nr_csi_bitlen(NR_UE_MAC_INST_t *mac) { - - uint16_t csi_bitlen =0; - uint16_t rsrp_bitlen = 0; - uint16_t diff_rsrp_bitlen = 0; - uint16_t nb_ssbri_cri = 0; - uint16_t cri_ssbri_bitlen = 0; - - NR_CSI_MeasConfig_t *csi_MeasConfig = mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; - struct NR_CSI_ResourceConfig__csi_RS_ResourceSetList__nzp_CSI_RS_SSB * nzp_CSI_RS_SSB = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[0]->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB; - - uint16_t nb_csi_ssb_report = nzp_CSI_RS_SSB->csi_SSB_ResourceSetList!=NULL ? nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.count:0; - - if (0 != nb_csi_ssb_report){ - uint8_t nb_ssb_resources =0; - - if (NULL != csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS) - nb_ssbri_cri = *(csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1; - else - nb_ssbri_cri = 1; - - nb_ssb_resources = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[0]->csi_SSB_ResourceList.list.count; - - if (nb_ssb_resources){ - cri_ssbri_bitlen =ceil(log2 (nb_ssb_resources)); - rsrp_bitlen = 7; - diff_rsrp_bitlen = 4; - } - else{ - cri_ssbri_bitlen =0; - rsrp_bitlen = 0; - diff_rsrp_bitlen = 0; - } - - csi_bitlen = ((cri_ssbri_bitlen * nb_ssbri_cri) + rsrp_bitlen +(diff_rsrp_bitlen *(nb_ssbri_cri -1 ))) *nb_csi_ssb_report; - - //printf("get csi bitlen %d nb_ssbri_cri %d nb_csi_report %d nb_resources %d\n", csi_bitlen,nb_ssbri_cri ,nb_csi_ssb_report, nb_ssb_resources); - } - return csi_bitlen; -} - -int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload) -{ - VOID_PARAMETER ue; - VOID_PARAMETER gNB_id; - float rsrp_db[7]; - int nElem = 98; - int rsrp_offset = 17; - int csi_status = 0; - - csi_status = get_nr_csi_bitlen(mac); - rsrp_db[0] = get_nr_RSRP(0,0,0); - - - if (csi_status == 0) { - *csi_payload = 0; - } - else { - *csi_payload = binary_search_float_nr(RSRP_meas_mapping_nr,nElem, rsrp_db[0]) + rsrp_offset; - } - - return (csi_status); -} /* FFS TODO_NR code that should be removed */ diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h index 101b80fb8d..37e24f43bc 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h @@ -41,8 +41,6 @@ /************** INCLUDE *******************************************/ #include "PHY/defs_nr_UE.h" -#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" -#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h" #include "RRC/NR_UE/rrc_proto.h" #ifdef DEFINE_VARIABLES_PUCCH_UE_NR_H @@ -65,31 +63,6 @@ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t *proc); -/** \brief This function check pucch format - @param ue context - @param gNB_id identity - @param format_pucch pucch format - @param nb_symbols_for_tx number of symbols for pucch transmission - @param uci size number of uci bits - @returns TRUE pucch format matched uci size and constraints, FALSE invalid pucch format */ - -boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, - int uci_size); - -/** \brief This function reads current CSI - @param ue context - @param gNB_id identity - @param csi_payload is updated with CSI - @returns number of bits of CSI */ - -int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload); - -/** \brief This dummy function sets current CSI for simulation - @param csi_status - @param csi_payload is updated with CSI - @returns none */ - -uint16_t get_nr_csi_bitlen(NR_UE_MAC_INST_t *mac); void set_csi_nr(int csi_status, uint32_t csi_payload); diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 3a34efbb93..833207a408 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -182,7 +182,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, if (UE->perfect_ce==1) { // fill in perfect channel estimates - freq_channel(eNB2UE[round],UE->frame_parms.N_RB_DL,12*UE->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[round],UE->frame_parms.N_RB_DL,12*UE->frame_parms.N_RB_DL + 1, 15); /* LOG_M("channel.m","ch",eNB2UE[round]->ch[0],eNB2UE[round]->channel_length,1,8); LOG_M("channelF.m","chF",eNB2UE[round]->chF[0],12*UE->frame_parms.N_RB_DL + 1,1,8); @@ -193,7 +193,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, if(abstx) { if (trials==0 && round==0) { // calculate freq domain representation to compute SINR - freq_channel(eNB2UE[0], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1); + freq_channel(eNB2UE[0], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1, 15); // snr=pow(10.0,.1*SNR); fprintf(csv_fd,"%f,",SNR); @@ -208,7 +208,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } if(num_rounds>1) { - freq_channel(eNB2UE[1], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1); + freq_channel(eNB2UE[1], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms->N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { @@ -220,7 +220,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } } - freq_channel(eNB2UE[2], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1); + freq_channel(eNB2UE[2], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms->N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { @@ -232,7 +232,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } } - freq_channel(eNB2UE[3], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1); + freq_channel(eNB2UE[3], ru->frame_parms->N_RB_DL,2*ru->frame_parms->N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms->N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 78fd1a293e..53c15ccc89 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -181,7 +181,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, if (UE->perfect_ce==1) { // fill in perfect channel estimates - freq_channel(eNB2UE[round],UE->frame_parms.N_RB_DL,12*UE->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[round],UE->frame_parms.N_RB_DL,12*UE->frame_parms.N_RB_DL + 1, 15); /* LOG_M("channel.m","ch",eNB2UE[round]->ch[0],eNB2UE[round]->channel_length,1,8); LOG_M("channelF.m","chF",eNB2UE[round]->chF[0],12*UE->frame_parms.N_RB_DL + 1,1,8); @@ -192,7 +192,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, if(abstx) { if (trials==0 && round==0) { // calculate freq domain representation to compute SINR - freq_channel(eNB2UE[0], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[0], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1, 15); // snr=pow(10.0,.1*SNR); fprintf(csv_fd,"%f,",SNR); @@ -207,7 +207,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } if(num_rounds>1) { - freq_channel(eNB2UE[1], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[1], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms.N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { @@ -219,7 +219,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } } - freq_channel(eNB2UE[2], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[2], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms.N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { @@ -231,7 +231,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, } } - freq_channel(eNB2UE[3], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1); + freq_channel(eNB2UE[3], ru->frame_parms.N_RB_DL,2*ru->frame_parms.N_RB_DL + 1, 15); for (u=0; u<2*ru->frame_parms.N_RB_DL; u++) { for (aarx=0; aarxnb_rx; aarx++) { diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 20a348f6c3..39593a640c 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -1102,7 +1102,7 @@ int main(int argc, char **argv) { if(saving_bler==0) if (trials==0 && round==0) { // calculate freq domain representation to compute SINR - freq_channel(UE2eNB, N_RB_DL,12*N_RB_DL + 1); + freq_channel(UE2eNB, N_RB_DL,12*N_RB_DL + 1, 15); // snr=pow(10.0,.1*SNR); fprintf(csv_fdUL,"%f,%u,%u,%f,%f,%f,",SNR,tx_lev,tx_lev_dB,sigma2_dB,tx_gain,SNR2); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 633a214699..a0e0183fd1 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -426,7 +426,9 @@ int main(int argc, char **argv) UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; + processingData_L1tx_t msgDataTx; + init_DLSCH_struct(gNB, &msgDataTx); + NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; //time_stats_t *rm_stats, *te_stats, *i_stats; uint8_t is_crnti = 0, llr8_flag = 0; @@ -634,7 +636,7 @@ int main(int argc, char **argv) for (i = 0; i < 2; i++) { printf("gNB %d\n", i); - free_gNB_dlsch(&(gNB->dlsch[0][i]),N_RB_DL); + free_gNB_dlsch(&(msgDataTx.dlsch[0][i]),N_RB_DL); printf("UE %d\n", i); free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL); } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 9c81443e0f..16c6c94bbe 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -27,6 +27,7 @@ #include #include "common/ran_context.h" #include "common/config/config_userapi.h" +#include "common/utils/nr/nr_common.h" #include "common/utils/LOG/log.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_UE/mac_defs.h" @@ -263,19 +264,23 @@ void nr_dlsim_preprocessor(module_id_t module_id, uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, - sched_ctrl->search_space); - sched_ctrl->coreset = get_coreset(scc, sched_ctrl->active_bwp, sched_ctrl->search_space, target_ss); + sched_ctrl->search_space,4); + sched_ctrl->coreset = get_coreset(module_id, scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); sched_ctrl->cce_index = 0; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = g_nrOfLayers; + int dci_format = sched_ctrl->search_space && sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats ? + NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; + nr_set_pdsch_semi_static(scc, UE_info->CellGroup[0], sched_ctrl->active_bwp, + NULL, /* tda = */ 2, - /* num_dmrs_cdm_grps_no_data = */ 1, + dci_format, ps); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; @@ -427,7 +432,9 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:d:e:m:w:T:U:q")) != -1) { + + while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:D:e:m:w:T:U:q")) != -1) { + switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -593,7 +600,7 @@ int main(int argc, char **argv) case 'b': g_rbSize = atoi(optarg); break; - case 'd': + case 'D': dlsch_threads = atoi(optarg); break; case 'e': @@ -666,7 +673,7 @@ int main(int argc, char **argv) printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n"); printf("-P Print DLSCH performances\n"); printf("-w Write txdata to binary file (one frame)\n"); - printf("-d number of dlsch threads, 0: no dlsch parallelization\n"); + printf("-D number of dlsch threads, 0: no dlsch parallelization\n"); exit (-1); break; } @@ -683,7 +690,7 @@ int main(int argc, char **argv) if (snr1set==0) snr1 = snr0+10; - init_dlsch_tpool(dlsch_threads); + RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); @@ -782,9 +789,9 @@ int main(int argc, char **argv) AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 0, 0, NULL); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, NULL, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); // reset preprocessor to the one of DLSIM after it has been set during // rrc_mac_config_req_gNB gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; @@ -931,8 +938,6 @@ int main(int argc, char **argv) // generate signal AssertFatal(input_fd==NULL,"Not ready for input signal file\n"); gNB->pbch_configured = 1; - gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; - gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0; //Configure UE rrc.carrier.MIB = (uint8_t*) malloc(4); @@ -962,11 +967,29 @@ int main(int argc, char **argv) //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels; snrRun = 0; - + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + char tp_param[] = "n"; + initTpool(tp_param, gNB->threadPool, true); + gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->resp_L1_tx); + // we create 2 threads for L1 tx processing + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); + processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + init_DLSCH_struct(gNB, msgDataTx); + msgDataTx->slot = slot; + msgDataTx->frame = frame; + memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + reset_meas(&msgDataTx->phy_proc_tx); + gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; + pushTpool(gNB->threadPool,msgL1Tx); + if (dlsch_threads ) { + init_dlsch_tpool(dlsch_threads); + pthread_t dlsch0_threads; + threadCreate(&dlsch0_threads, dlsch_thread, (void *)UE, "DLthread", -1, OAI_PRIORITY_RT_MAX-1); + } for (SNR = snr0; SNR < snr1; SNR += .2) { varArray_t *table_tx=initVarArray(1000,sizeof(double)); - reset_meas(&gNB->phy_proc_tx); // total gNB tx reset_meas(&gNB->dlsch_scrambling_stats); reset_meas(&gNB->dlsch_interleaving_stats); reset_meas(&gNB->dlsch_rate_matching_stats); @@ -1007,7 +1030,7 @@ int main(int argc, char **argv) int harq_pid = slot; NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid]; - NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0]; + NR_gNB_DLSCH_t *gNB_dlsch = msgDataTx->dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; UE_harq_process->ack = 0; @@ -1058,10 +1081,14 @@ int main(int argc, char **argv) ptrsRePerSymb = ((rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity); printf("[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); } + + msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; + msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0; + msgDataTx->gNB = gNB; if (run_initial_sync) - nr_common_signal_procedures(gNB,frame,slot,gNB->ssb[0].ssb_pdu); + nr_common_signal_procedures(gNB,frame,slot,msgDataTx->ssb[0].ssb_pdu); else - phy_procedures_gNB_TX(gNB,frame,slot,1); + phy_procedures_gNB_TX(msgDataTx,frame,slot,1); int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP; @@ -1263,17 +1290,17 @@ int main(int argc, char **argv) (float) n_errors / (float) n_trials); printf("*****************************************\n"); printf("\n"); - dump_pdsch_stats(gNB); + dump_pdsch_stats(stdout,gNB); printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, BLER %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],berStats[snrRun],blerStats[snrRun],effRate,effRate/TBS*100,TBS); printf("\n"); if (print_perf==1) { printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n", 1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, - gNB->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, - gNB->dlsch[0][0]->harq_process.K, - gNB->dlsch[0][0]->harq_process.K/((gNB->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); - printDistribution(&gNB->phy_proc_tx,table_tx,"PHY proc tx"); + msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, + msgDataTx->dlsch[0][0]->harq_process.K, + msgDataTx->dlsch[0][0]->harq_process.K/((msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); + printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time"); @@ -1326,6 +1353,8 @@ int main(int argc, char **argv) LOG_M("chestF0.m","chF0",&UE->pdsch_vars[0][0]->dl_ch_estimates_ext[0][0],g_rbSize*12*14,1,1); write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); LOG_M("rxF_llr.m","rxFllr",UE->pdsch_vars[UE_proc.thread_id][0]->llr[0],available_bits,1,0); + LOG_M("pdcch_rxFcomp.m","pdcch_rxFcomp",&UE->pdcch_vars[0][0]->rxdataF_comp[0][0],96*12,1,1); + LOG_M("pdcch_rxFllr.m","pdcch_rxFllr",UE->pdcch_vars[0][0]->llr,96*12,1,1); break; } diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 46b42666b5..1169b8ecd8 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -28,6 +28,7 @@ #include "common/config/config_userapi.h" #include "common/utils/LOG/log.h" #include "common/ran_context.h" +#include "common/utils/nr/nr_common.h" #include "PHY/types.h" #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" @@ -565,14 +566,15 @@ int main(int argc, char **argv) nr_gold_pbch(UE); + processingData_L1tx_t msgDataTx; // generate signal if (input_fd==NULL) { for (i=0; iLmax; i++) { if((SSB_positions >> i) & 0x01) { - gNB->ssb[i].ssb_pdu.ssb_pdu_rel15.bchPayload = 0x55dd33; - gNB->ssb[i].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = i; + msgDataTx.ssb[i].ssb_pdu.ssb_pdu_rel15.bchPayload = 0x55dd33; + msgDataTx.ssb[i].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = i; start_symbol = nr_get_ssb_start_symbol(frame_parms,i); int slot = start_symbol/14; @@ -580,7 +582,7 @@ int main(int argc, char **argv) for (aa=0; aaframe_parms.nb_antennas_tx; aa++) memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t)); - nr_common_signal_procedures (gNB,frame,slot,gNB->ssb[i].ssb_pdu); + nr_common_signal_procedures (gNB,frame,slot,msgDataTx.ssb[i].ssb_pdu); for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { if (cyclic_prefix_type == 1) { @@ -750,7 +752,7 @@ int main(int argc, char **argv) payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte); for (i=0;i<3;i++){ - payload_ret += (UE->pbch_vars[0]->decoded_output[i] == ((gNB->ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); + payload_ret += (UE->pbch_vars[0]->decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); } //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->pbch_vars[0]->xtra_byte); //printf("ret %d\n", payload_ret); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 96f6fe4990..6b9512a38b 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -47,6 +47,7 @@ #include "nr_unitary_defs.h" #include "OCG_vars.h" #include +#include #include #include #include diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index a3eb4452d7..0aed6d9780 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -67,7 +67,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} int main(int argc, char **argv) { char c; - int i,aa=0;//,l; + int i;//,l; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; double cfo=0; uint8_t snr1set=0; @@ -104,7 +104,8 @@ int main(int argc, char **argv) SCM_t channel_model=AWGN;//Rayleigh1_anticorr; double DS_TDL = .03; - + + double delay_us = 0; int N_RB_DL=273,mu=1; float target_error_rate=0.001; int frame_length_complex_samples; @@ -113,7 +114,7 @@ int main(int argc, char **argv) //unsigned char frame_type = 0; int loglvl=OAILOG_WARNING; int sr_flag = 0; - + int pucch_DTX_thres = 50; cpuf = get_cpu_freq_GHz(); if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) { @@ -123,7 +124,7 @@ int main(int argc, char **argv) randominit(0); logInit(); - while ((c = getopt (argc, argv, "f:hA:f:g:i:I:P:B:b:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:c")) != -1) { + while ((c = getopt (argc, argv, "f:hA:f:g:i:I:P:B:b:t:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:cd:")) != -1) { switch (c) { case 'f': //write_output_file=1; @@ -207,11 +208,11 @@ int main(int argc, char **argv) printf("Setting SNR1 to %f\n",snr1); break; - /* + case 't': - Td= atof(optarg); + pucch_DTX_thres= atoi(optarg); break; - + /* case 'p': extended_prefix_flag=1; break; @@ -228,6 +229,9 @@ int main(int argc, char **argv) } break; */ + case 'd': + delay_us=atof(optarg); + break; case 'x': transmission_mode=atoi(optarg); @@ -251,7 +255,7 @@ int main(int argc, char **argv) case 'z': n_rx=atoi(optarg); - if ((n_rx==0) || (n_rx>2)) { + if ((n_rx==0) || (n_rx>8)) { printf("Unsupported number of rx antennas %d\n",n_rx); exit(-1); } @@ -346,29 +350,33 @@ int main(int argc, char **argv) } } + double phase = (1<2)&&(nr_bit<65)),"illegal combination format %d, nr_bit %d\n", format,nr_bit); + int do_DTX=0; + if ((format < 2) && (actual_payload == 4)) do_DTX=1; actual_payload &= ((1<pucch0_thres = pucch_DTX_thres; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; @@ -430,31 +438,28 @@ int main(int argc, char **argv) frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; - s_re = malloc(2*sizeof(double*)); - s_im = malloc(2*sizeof(double*)); - r_re = malloc(2*sizeof(double*)); - r_im = malloc(2*sizeof(double*)); - txdataF = malloc(2*sizeof(int*)); - rxdataF = malloc(2*sizeof(int*)); + s_re = malloc(n_tx*sizeof(double*)); + s_im = malloc(n_tx*sizeof(double*)); + r_re = malloc(n_rx*sizeof(double*)); + r_im = malloc(n_rx*sizeof(double*)); + txdataF = malloc(n_tx*sizeof(int*)); + rxdataF = malloc(n_rx*sizeof(int*)); gNB->common_vars.rxdataF=rxdataF; memcpy((void*)&gNB->frame_parms,(void*)frame_parms,sizeof(frame_parms)); - for (i=0; i<2; i++) { + for (int aatx=0; aatxsymbols_per_slot*frame_parms->ofdm_symbol_size); + txdataF[aatx] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int)); + bzero(txdataF[aatx],14*frame_parms->ofdm_symbol_size*sizeof(int)); + } - s_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_re[i],frame_length_complex_samples*sizeof(double)); - s_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_im[i],frame_length_complex_samples*sizeof(double)); - - r_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_re[i],frame_length_complex_samples*sizeof(double)); - r_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_im[i],frame_length_complex_samples*sizeof(double)); - - printf("Allocating %d samples for txdataF/rxdataF\n",14*frame_parms->ofdm_symbol_size); - txdataF[i] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int)); - bzero(txdataF[i],14*frame_parms->ofdm_symbol_size*sizeof(int)); - rxdataF[i] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int)); - bzero(rxdataF[i],14*frame_parms->ofdm_symbol_size*sizeof(int)); + for (int aarx=0; aarxsymbols_per_slot*frame_parms->ofdm_symbol_size); + rxdataF[aarx] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int)); + bzero(rxdataF[aarx],14*frame_parms->ofdm_symbol_size*sizeof(int)); } uint8_t mcs=0; @@ -471,14 +476,26 @@ int main(int argc, char **argv) else AssertFatal(1==0,"Either nr_bit %d or sr_flag %d must be non-zero\n", nr_bit, sr_flag); } else if (format == 2 && nr_bit > 11) gNB->uci_polarParams = nr_polar_params(2, nr_bit, nrofPRB, 1, NULL); - - startingPRB_intraSlotHopping=N_RB_DL-1; - uint32_t hopping_id=Nid_cell; - uint32_t dmrs_scrambling_id = 0, data_scrambling_id=0; + + startingPRB_intraSlotHopping = N_RB_DL-1; + uint32_t hopping_id = Nid_cell; + uint32_t dmrs_scrambling_id = 0; + uint32_t data_scrambling_id = 0; //configure UE - UE = malloc(sizeof(PHY_VARS_NR_UE)); + UE = calloc(1,sizeof(PHY_VARS_NR_UE)); memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); + UE->frame_parms.nb_antennas_rx=1; + UE->perfect_ce = 0; + + if(eps!=0.0) + UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation + + if (init_nr_ue_signal(UE, 1, 0) != 0) + { + printf("Error at UE NR initialisation\n"); + exit(-1); + } fapi_nr_ul_config_pucch_pdu pucch_tx_pdu; if (format==0) { @@ -514,80 +531,112 @@ int main(int argc, char **argv) pucch_tx_pdu.second_hop_prb = startingPRB_intraSlotHopping; } - UE->perfect_ce = 0; - - if(eps!=0.0) - UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation - - if (init_nr_ue_signal(UE, 1, 0) != 0) - { - printf("Error at UE NR initialisation\n"); - exit(-1); - } - pucch_GroupHopping_t PUCCH_GroupHopping = pucch_tx_pdu.group_hop_flag + (pucch_tx_pdu.sequence_hop_flag<<1); - //t_nrPolar_params *currentPtr; - - for(SNR=snr0;SNR<=snr1;SNR=SNR+1){ + for(SNR=snr0;SNR<=snr1;SNR+=1){ ack_nack_errors=0; sr_errors=0; n_errors = 0; for (trial=0; trialofdm_symbol_size*sizeof(int)); - if(format==0){ - nr_generate_pucch0(UE, - txdataF, - frame_parms, - amp, - nr_slot_tx, - &pucch_tx_pdu); + for (int aatx=0;aatx<1;aatx++) + bzero(txdataF[aatx],frame_parms->ofdm_symbol_size*sizeof(int)); + if(format==0 && do_DTX==0){ + nr_generate_pucch0(UE, txdataF, frame_parms, amp, nr_slot_tx, &pucch_tx_pdu); + } else if (format == 1 && do_DTX==0){ + nr_generate_pucch1(UE, txdataF, frame_parms, amp, nr_slot_tx, &pucch_tx_pdu); + } else if (do_DTX == 0){ + nr_generate_pucch2(UE, txdataF, frame_parms, amp, nr_slot_tx, &pucch_tx_pdu); } - else if (format == 1){ - nr_generate_pucch1(UE, - txdataF, - frame_parms, - amp, - nr_slot_tx, - &pucch_tx_pdu); - } - else { - nr_generate_pucch2(UE, - txdataF, - frame_parms, - amp, - nr_slot_tx, - &pucch_tx_pdu); - } - - int txlev = signal_energy(&txdataF[aa][startingSymbolIndex*frame_parms->ofdm_symbol_size], - frame_parms->ofdm_symbol_size); - // printf("txlev %d (%d dB), offset %d\n",txlev,dB_fixed(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size); - - // note : this scaling - int nb_re = (format == 0 || format == 1)? 12 : 12*nrofPRB; - sigma2_dB = 10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/nb_re)-SNR; - sigma2 = pow(10,sigma2_dB/10); - - for(i=startingSymbolIndex*frame_parms->ofdm_symbol_size; i<(startingSymbolIndex+1)*frame_parms->ofdm_symbol_size; i++) { - ((int16_t*)rxdataF[aa])[i<<1] = (int16_t)(100.0*((double)(((int16_t *)txdataF[aa])[(i<<1)]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0))/sqrt((double)txlev)); - ((int16_t*)rxdataF[aa])[1+(i<<1)]=(int16_t)(100.0*((double)(((int16_t *)txdataF[aa])[(i<<1)+1])+ sqrt(sigma2/2)*gaussdouble(0.0,1.0))/sqrt((double)txlev)); - } - int rxlev = signal_energy(&rxdataF[aa][startingSymbolIndex*frame_parms->ofdm_symbol_size], - frame_parms->ofdm_symbol_size); - // noise measurement - gNB->ulmask_symb = startingSymbolIndex; - for (int rb=0; rbrb_mask_ul[rb2>>5] |= (1<<(rb2&31)); - } - gNB_I0_measurements(gNB, startingSymbolIndex, nrofSymbols); + // SNR Computation + // standard says: SNR = S / N, where S is the total signal energy, N is the noise energy in the transmission bandwidth (i.e. N_RB_DL resource blocks) + // txlev = S. + int txlev = signal_energy(&txdataF[0][startingSymbolIndex*frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size); - if (n_trials==1) printf("rxlev %d (%d dB), sigma2 %f dB, SNR %f, TX %f\n",rxlev,dB_fixed(rxlev),sigma2_dB,SNR,10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/12)); + // sigma2 is variance per dimension, so N/(N_RB*12) + // so, sigma2 = N/(N_RB_DL*12) => (S/SNR)/(N_RB*12) + int N_RB = (format == 0 || format == 1) ? 1 : nrofPRB; + sigma2_dB = 10*log10(txlev*(N_RB_DL/N_RB))-SNR; + sigma2 = pow(10.0,sigma2_dB/10.0); + + if (n_trials==1) printf("txlev %d (%f dB), offset %d, sigma2 %f ( %f dB)\n",txlev,10*log10(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size,sigma2,sigma2_dB); + + int i0; + double txr,txi,rxr,rxi,nr,ni; + for (int symb=0; symbframe_parms.symbols_per_slot;symb++) { + if (symb= startingSymbolIndex+nrofSymbols) { + i0 = symb*gNB->frame_parms.ofdm_symbol_size; + for (int re=0;reframe_parms.first_carrier_offset + re)%gNB->frame_parms.ofdm_symbol_size); + for (int aarx=0;aarxframe_parms.ofdm_symbol_size; + for (int re=0;reframe_parms.first_carrier_offset + re)%gNB->frame_parms.ofdm_symbol_size); + phasor.r = cos(2*M_PI*phase*re); + phasor.i = sin(2*M_PI*phase*re); + for (int aarx=0;aarxchF[aarx][re].r - txi*UE2gNB->chF[aarx][re].i; + rxi = txr*UE2gNB->chF[aarx][re].i + txi*UE2gNB->chF[aarx][re].r; + rxr_tmp = rxr*phasor.r - rxi*phasor.i; + rxi = rxr*phasor.i + rxi*phasor.r; + rxr = rxr_tmp; + nr = sqrt(sigma2/2)*gaussdouble(0.0,1.0); + ni = sqrt(sigma2/2)*gaussdouble(0.0,1.0); + ((int16_t*)rxdataF[aarx])[i<<1] = (int16_t)(100.0*(rxr + nr)/sqrt((double)txlev)); + ((int16_t*)rxdataF[aarx])[1+(i<<1)]=(int16_t)(100.0*(rxi + ni)/sqrt((double)txlev)); + + if (n_trials==1 && abs(txr) > 0) printf("symb %d, re %d , aarx %d : txr %f, txi %f, chr %f, chi %f, nr %f, ni %f, rxr %f, rxi %f => %d,%d\n", + symb, re, aarx, txr,txi, + UE2gNB->chF[aarx][re].r,UE2gNB->chF[aarx][re].i, + nr,ni, rxr,rxi, + ((int16_t*)rxdataF[aarx])[i<<1],((int16_t*)rxdataF[aarx])[1+(i<<1)]); + } + } + } + + int rxlev=0; + for (int aarx=0;aarxofdm_symbol_size], + frame_parms->ofdm_symbol_size); + + int rxlev_pucch=0; + + for (int aarx=0;aarxofdm_symbol_size], + 12); + + // set UL mask for pucch allocation + for (int s=0;ssymbols_per_slot;s++){ + if (s>=startingSymbolIndex && s<(startingSymbolIndex+nrofSymbols)) + for (int rb=0; rbrb_mask_ul[s][rb2>>5] |= (1<<(rb2&31)); + } + } + + // noise measurement (all PRBs) + gNB_I0_measurements(gNB, nr_slot_tx, 0, gNB->frame_parms.symbols_per_slot); + + if (n_trials==1) printf("noise rxlev %d (%d dB), rxlev pucch %d dB sigma2 %f dB, SNR %f, TX %f, I0 (pucch) %d, I0 (avg) %d\n",rxlev,dB_fixed(rxlev),dB_fixed(rxlev_pucch),sigma2_dB,SNR,10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/12),gNB->measurements.n0_subband_power_tot_dB[startingPRB],gNB->measurements.n0_subband_power_avg_dB); if(format==0){ nfapi_nr_uci_pucch_pdu_format_0_1_t uci_pdu; nfapi_nr_pucch_pdu_t pucch_pdu; + gNB->uci_stats[0].rnti = 0x1234; + pucch_pdu.rnti = 0x1234; pucch_pdu.subcarrier_spacing = 1; pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1; pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1; @@ -601,18 +650,27 @@ int main(int argc, char **argv) pucch_pdu.start_symbol_index = startingSymbolIndex; pucch_pdu.prb_start = startingPRB; pucch_pdu.bwp_start = 0; - pucch_pdu.freq_hop_flag = 0; + pucch_pdu.bwp_size = N_RB_DL; + if (nrofSymbols>1) { + pucch_pdu.freq_hop_flag = 1; + pucch_pdu.second_hop_prb = N_RB_DL-1; + } + else pucch_pdu.freq_hop_flag = 0; + nr_decode_pucch0(gNB, nr_frame_tx, nr_slot_tx,&uci_pdu,&pucch_pdu); if(sr_flag==1){ if (uci_pdu.sr->sr_indication == 0 || uci_pdu.sr->sr_confidence_level == 1) sr_errors+=1; } if(nr_bit>0){ - if(nr_bit==1) + if (nr_bit==1 && do_DTX == 0) ack_nack_errors+=(actual_payload^uci_pdu.harq->harq_list[0].harq_value); - else + else if (do_DTX == 0) ack_nack_errors+=(((actual_payload&1)^uci_pdu.harq->harq_list[0].harq_value)+((actual_payload>>1)^uci_pdu.harq->harq_list[1].harq_value)); - free(uci_pdu.harq->harq_list); + else if ((uci_pdu.harq->harq_confidence_level == 0 && uci_pdu.harq->harq_list[0].harq_value == 1) || + (uci_pdu.harq->harq_confidence_level == 0 && nr_bit == 2 && uci_pdu.harq->harq_list[1].harq_value==1)) + ack_nack_errors++; + free(uci_pdu.harq->harq_list); } } else if (format==1) { @@ -644,6 +702,11 @@ int main(int argc, char **argv) pucch_pdu.prb_start = startingPRB; pucch_pdu.dmrs_scrambling_id = dmrs_scrambling_id; pucch_pdu.data_scrambling_id = data_scrambling_id; + if (nrofSymbols>1) { + pucch_pdu.freq_hop_flag = 1; + pucch_pdu.second_hop_prb = N_RB_DL-1; + } + else pucch_pdu.freq_hop_flag = 0; nr_decode_pucch2(gNB,nr_slot_tx,&uci_pdu,&pucch_pdu); int csi_part1_bytes=pucch_pdu.bit_len_csi_part1>>3; if ((pucch_pdu.bit_len_csi_part1&7) > 0) csi_part1_bytes++; @@ -668,13 +731,15 @@ int main(int argc, char **argv) } } - for (i=0; i<2; i++) { - free(s_re[i]); - free(s_im[i]); - free(r_re[i]); - free(r_im[i]); - free(txdataF[i]); - free(rxdataF[i]); + for (int aatx=0; aatx 2)) { + if ((n_rx == 0) || (n_rx > 8)) { printf("Unsupported number of rx antennas %d\n", n_rx); exit(-1); } @@ -673,8 +666,15 @@ int main(int argc, char **argv) gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); char tp_param[] = "n"; - initTpool(tp_param, gNB->threadPool, true); + initTpool(tp_param, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); + gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->resp_L1_tx); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,NULL); + processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + msgDataTx->slot = -1; + gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; + pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning //gNB_config = &gNB->gNB_config; //memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); @@ -685,13 +685,14 @@ int main(int argc, char **argv) gNB->prb_interpolation = prb_inter; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) - - //frame_parms->nb_antennas_tx = n_tx; - //frame_parms->nb_antennas_rx = n_rx; frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_UL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; + s_re = malloc(n_tx*sizeof(double*)); + s_im = malloc(n_tx*sizeof(double*)); + r_re = malloc(n_rx*sizeof(double*)); + r_im = malloc(n_rx*sizeof(double*)); RC.nb_nr_macrlc_inst = 1; RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); @@ -726,9 +727,15 @@ int main(int argc, char **argv) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 0, 0, NULL); + rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, scc, &rrc.carrier.mib,0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, scc, &rrc.carrier.mib,1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + frame_parms->nb_antennas_tx = n_tx; + frame_parms->nb_antennas_rx = n_rx; + nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; + cfg->carrier_config.num_tx_ant.value = n_tx; + cfg->carrier_config.num_rx_ant.value = n_rx; + nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; @@ -770,8 +777,16 @@ int main(int argc, char **argv) } } */ - - nr_l2_init_ue(NULL); + + //Configure UE + NR_UE_RRC_INST_t rrcue; + memset(&rrcue,0,sizeof(NR_UE_RRC_INST_t)); + rrc.carrier.MIB = (uint8_t*) malloc(4); + rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); + rrcue.mib = rrc.carrier.mib.message.choice.mib; + rrcue.scell_group_config=secondaryCellGroup; + nr_l2_init_ue(&rrcue); + NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); UE->if_inst = nr_ue_if_module_init(0); @@ -782,11 +797,7 @@ int main(int argc, char **argv) UE_mac->if_module = nr_ue_if_module_init(0); - //Configure UE - rrc.carrier.MIB = (uint8_t*) malloc(4); - rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); - - nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup); +// nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup); nr_ue_phy_config_request(&UE_mac->phy_config); @@ -854,12 +865,13 @@ int main(int argc, char **argv) { add_pos = dmrs_arg[1]; } - printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos ); } + printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos ); uint8_t length_dmrs = pusch_len1; uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2); uint16_t number_dmrs_symbols = get_dmrs_symbols_in_slot(l_prime_mask, nb_symb_sch); + printf("num dmrs sym %d\n",number_dmrs_symbols); uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4; // if transform precoding is enabled @@ -871,11 +883,11 @@ int main(int argc, char **argv) AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); dmrs_config_type = pusch_dmrs_type1; - nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index); } + nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1); unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); @@ -917,13 +929,24 @@ int main(int argc, char **argv) printf("NOTE: PTRS Enabled with L %d, K %d \n", ptrs_time_density, ptrs_freq_density ); } - if (input_fd != NULL) max_rounds=1; + if (input_fd != NULL || n_trials == 1) max_rounds=1; if(1<= nb_symb_sch) pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS printf("\n"); + int frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + for (int aatx=0; aatxcommon_vars.rxdata[0][slot_offset])[i], @@ -975,14 +1001,24 @@ int main(int argc, char **argv) code_rate = nr_get_code_rate_ul(Imcs, mcs_table); } + uint32_t errors_scrambling[4][100]; + int n_errors[4][100]; + int round_trials[4][100]; + double blerStats[4][100]; + double berStats[4][100]; + double snrStats[100]; + memset(errors_scrambling, 0, sizeof(uint32_t)*4*100); + memset(n_errors, 0, sizeof(int)*4*100); + memset(round_trials, 0, sizeof(int)*4*100); + memset(blerStats, 0, sizeof(double)*4*100); + memset(berStats, 0, sizeof(double)*4*100); + memset(snrStats, 0, sizeof(double)*100); for (SNR = snr0; SNR < snr1; SNR += snr_step) { varArray_t *table_rx=initVarArray(1000,sizeof(double)); int error_flag = 0; n_false_positive = 0; - effRate = 0; - int n_errors[4] = {0,0,0,0};; - int round_trials[4]={0,0,0,0}; - uint32_t errors_scrambling[4] = {0,0,0,0}; + effRate[snrRun] = 0; + effTP[snrRun] = 0; reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->rx_pusch_stats); reset_meas(&gNB->ulsch_decoding_stats); @@ -1007,7 +1043,7 @@ int main(int argc, char **argv) errors_decoding = 0; memset((void*)roundStats,0,50*sizeof(roundStats[0])); while (roundharq_processes[harq_pid]->round = round; gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round; rv_index = nr_rv_round_map[round]; @@ -1057,7 +1093,7 @@ int main(int argc, char **argv) pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; pusch_pdu->scid = 0; pusch_pdu->dmrs_ports = 1; - pusch_pdu->num_dmrs_cdm_grps_no_data = msg3_flag == 0 ? 1 : 2; + pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; pusch_pdu->resource_alloc = 1; pusch_pdu->rb_start = start_rb; pusch_pdu->rb_size = nb_rb; @@ -1120,7 +1156,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs; ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = msg3_flag == 0 ? 1 : 2; + ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; @@ -1265,6 +1301,58 @@ int main(int argc, char **argv) (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); LOG_M("rxsigF0_comp.m","rxsF0_comp", &gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chmagF0.m","chmF0", + &gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chmagbF0.m","chmbF0", + &gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + if (n_rx == 2) { + LOG_MM("rxsigF0_comp.m","rxsF1_comp", + &gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_ext.m","rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chestF0_ext.m","chF1_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagF0.m","chmF1", + &gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagbF0.m","chmbF1", + &gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + } else if (n_rx == 4) { + LOG_MM("rxsigF0_comp.m","rxsF1_comp", + &gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_comp.m","rxsF2_comp", + &gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_comp.m","rxsF3_comp", + &gNB->pusch_vars[0]->rxdataF_comp[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_ext.m","rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_ext.m","rxsF2_ext", + &gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("rxsigF0_ext.m","rxsF3_ext", + &gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chestF0_ext.m","chF1_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chestF0_ext.m","chF2_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[2][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chestF0_ext.m","chF3_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagF0.m","chmF1", + &gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagF0.m","chmF2", + &gNB->pusch_vars[0]->ul_ch_mag[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagF0.m","chmF3", + &gNB->pusch_vars[0]->ul_ch_mag[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagbF0.m","chmbF1", + &gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagbF0.m","chmbF2", + &gNB->pusch_vars[0]->ul_ch_magb[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_MM("chmagbF0.m","chmbF3", + &gNB->pusch_vars[0]->ul_ch_magb[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + } + LOG_M("rxsigF0_llr.m","rxsF0_llr", &gNB->pusch_vars[0]->llr[0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); } @@ -1273,7 +1361,7 @@ int main(int argc, char **argv) if ((gNB->ulsch[0][0]->last_iteration_cnt >= gNB->ulsch[0][0]->max_ldpc_iterations+1) || ul_proc_error == 1) { error_flag = 1; - n_errors[round]++; + n_errors[round][snrRun]++; crc_status = 1; } else { crc_status = 0; @@ -1301,15 +1389,15 @@ int main(int argc, char **argv) { /*if(errors_scrambling == 0) printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ - errors_scrambling[round]++; + errors_scrambling[round][snrRun]++; } } round++; } // round - if (n_trials == 1 && errors_scrambling[0] > 0) { - printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0]); + if (n_trials == 1 && errors_scrambling[0][snrRun] > 0) { + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0][snrRun]); } for (i = 0; i < TBS; i++) { @@ -1326,8 +1414,8 @@ int main(int argc, char **argv) if (n_trials == 1) { for (int r=0;rharq_processes[harq_pid]->C;r++) for (int i=0;iharq_processes[harq_pid]->K>>3;i++) { - /*if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************"); - printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, + if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************"); + /*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, i,ulsch_ue[0]->harq_processes[harq_pid]->c[r][i], i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/ @@ -1339,26 +1427,36 @@ int main(int argc, char **argv) printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %u\n" "\x1B[0m", frame, trial, errors_decoding); } roundStats[snrRun] += ((float)round); - if (!crc_status) effRate += ((float)TBS)/round; + if (!crc_status) effRate[snrRun] += ((double)TBS)/(double)round; } // trial loop roundStats[snrRun]/=((float)n_trials); - effRate /= n_trials; + effRate[snrRun] /= (double)n_trials; printf("*****************************************\n"); - printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0], round_trials[0],n_errors[1], round_trials[1],n_errors[2], round_trials[2],n_errors[3], round_trials[3], n_false_positive, n_trials, errors_scrambling[0],available_bits*n_trials,errors_scrambling[1],available_bits*n_trials,errors_scrambling[2],available_bits*n_trials,errors_scrambling[3],available_bits*n_trials); + printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0][snrRun], round_trials[0][snrRun],n_errors[1][snrRun], round_trials[1][snrRun],n_errors[2][snrRun], round_trials[2][snrRun],n_errors[3][snrRun], round_trials[3][snrRun], n_false_positive, n_trials, errors_scrambling[0][snrRun],available_bits*n_trials,errors_scrambling[1][snrRun],available_bits*n_trials,errors_scrambling[2][snrRun],available_bits*n_trials,errors_scrambling[3][snrRun],available_bits*n_trials); printf("\n"); + blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun]; + blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun]; + blerStats[2][snrRun] = (double)n_errors[2][snrRun]/round_trials[2][snrRun]; + blerStats[3][snrRun] = (double)n_errors[3][snrRun]/round_trials[3][snrRun]; + + berStats[0][snrRun] = (double)errors_scrambling[0][snrRun]/available_bits/round_trials[0][snrRun]; + berStats[1][snrRun] = (double)errors_scrambling[1][snrRun]/available_bits/round_trials[1][snrRun]; + berStats[2][snrRun] = (double)errors_scrambling[2][snrRun]/available_bits/round_trials[2][snrRun]; + berStats[3][snrRun] = (double)errors_scrambling[3][snrRun]/available_bits/round_trials[3][snrRun]; + effTP[snrRun] = effRate[snrRun]/(double)TBS*(double)100; printf("SNR %f: Channel BLER (%e,%e,%e,%e), Channel BER (%e,%e,%e,%e) Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", SNR, - (double)n_errors[0]/round_trials[0], - (double)n_errors[1]/round_trials[0], - (double)n_errors[2]/round_trials[0], - (double)n_errors[3]/round_trials[0], - (double)errors_scrambling[0]/available_bits/round_trials[0], - (double)errors_scrambling[1]/available_bits/round_trials[0], - (double)errors_scrambling[2]/available_bits/round_trials[0], - (double)errors_scrambling[3]/available_bits/round_trials[0], - roundStats[snrRun],effRate,effRate/TBS*100,TBS); + blerStats[0][snrRun], + blerStats[1][snrRun], + blerStats[2][snrRun], + blerStats[3][snrRun], + berStats[0][snrRun], + berStats[1][snrRun], + berStats[2][snrRun], + berStats[3][snrRun], + roundStats[snrRun],effRate[snrRun],effTP[snrRun],TBS); FILE *fd=fopen("nr_ulsim.log","w"); dump_pusch_stats(fd,gNB); @@ -1391,18 +1489,47 @@ int main(int argc, char **argv) if(n_trials==1) break; - if ((float)n_errors[0]/(float)n_trials <= target_error_rate) { + if ((float)n_errors[0][snrRun]/(float)n_trials <= target_error_rate) { printf("*************\n"); printf("PUSCH test OK\n"); printf("*************\n"); break; } + snrStats[snrRun] = SNR; snrRun++; - n_errs = n_errors[0]; + n_errs = n_errors[0][snrRun]; } // SNR loop printf("\n"); + printf( "Num RB:\t%d\n" + "Num symbols:\t%d\n" + "MCS:\t%d\n" + "DMRS config type:\t%d\n" + "DMRS add pos:\t%d\n" + "PUSCH mapping type:\t%d\n" + "DMRS length:\t%d\n" + "DMRS CDM gr w/o data:\t%d\n", + nb_rb, + nb_symb_sch, + Imcs, + dmrs_config_type, + add_pos, + mapping_type, + length_dmrs, + num_dmrs_cdm_grps_no_data); + + LOG_M("ulsimStats.m","SNR",snrStats,snrRun,1,7); + LOG_MM("ulsimStats.m","BLER_round0",blerStats[0],snrRun,1,7); + LOG_MM("ulsimStats.m","BLER_round1",blerStats[1],snrRun,1,7); + LOG_MM("ulsimStats.m","BLER_round2",blerStats[2],snrRun,1,7); + LOG_MM("ulsimStats.m","BLER_round3",blerStats[3],snrRun,1,7); + LOG_MM("ulsimStats.m","BER_round0",berStats[0],snrRun,1,7); + LOG_MM("ulsimStats.m","BER_round1",berStats[1],snrRun,1,7); + LOG_MM("ulsimStats.m","BER_round2",berStats[2],snrRun,1,7); + LOG_MM("ulsimStats.m","BER_round3",berStats[3],snrRun,1,7); + LOG_MM("ulsimStats.m","EffRate",effRate,snrRun,1,7); + LOG_MM("ulsimStats.m","EffTP",effTP,snrRun,1,7); free(test_input_bit); free(estimated_output_bit); diff --git a/openair1/SIMULATION/TOOLS/abstraction.c b/openair1/SIMULATION/TOOLS/abstraction.c index d19afcd030..a6b0586882 100644 --- a/openair1/SIMULATION/TOOLS/abstraction.c +++ b/openair1/SIMULATION/TOOLS/abstraction.c @@ -39,7 +39,7 @@ double **cos_lut=NULL,* *sin_lut=NULL; -int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) { +int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs) { double delta_f,freq; // 90 kHz spacing double delay; int16_t f; @@ -52,7 +52,7 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) { cos_lut = (double **)malloc(n_samples*sizeof(double *)); sin_lut = (double **)malloc(n_samples*sizeof(double *)); - delta_f = nb_rb*180000/(n_samples-1); + delta_f = nb_rb*12*scs*1000/(n_samples-1); for (f=-(n_samples>>1); f<=(n_samples>>1); f++) { freq=delta_f*(double)f*1e-6;// due to the fact that delays is in mus @@ -67,14 +67,14 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) { cos_lut[f+(n_samples>>1)][l] = cos(2*M_PI*freq*delay); sin_lut[f+(n_samples>>1)][l] = sin(2*M_PI*freq*delay); - //printf("values cos:%d, sin:%d\n", cos_lut[f][l], sin_lut[f][l]); + // printf("values cos:%f, sin:%f\n", cos_lut[f+(n_samples>>1)][l], sin_lut[f+(n_samples>>1)][l]); } } return(0); } -int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) { +int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs) { int16_t f,f2,d; uint8_t aarx,aatx,l; double *clut,*slut; @@ -95,14 +95,14 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) { // if called with n_samples<12*nb_rb+1, we decimate the lut n_samples_max=12*nb_rb+1; - if (init_freq_channel(desc,nb_rb,n_samples_max)==0) + if (init_freq_channel(desc,nb_rb,n_samples_max,scs)==0) freq_channel_init=1; else return(-1); } d=(n_samples_max-1)/(n_samples-1); - //printf("no_samples=%d, n_samples_max=%d, d=%d\n",n_samples,n_samples_max,d); + // printf("no_samples=%d, n_samples_max=%d, d=%d,nb_taps %d\n",n_samples,n_samples_max,d,desc->nb_taps); start_meas(&desc->interp_freq); for (f=-n_samples_max/2,f2=-n_samples/2; fnb_rx; aarx++) { for (aatx=0; aatxnb_tx; aatx++) { + AssertFatal(n_samples/2+f2 < (2+(275*12)),"reading past chF %d (n_samples %d, f2 %d)\n",n_samples/2+f2,n_samples,f2); desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].r=0.0; desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].i=0.0; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index d393bb1342..f09d1a7ce1 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -519,12 +519,12 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS chan_desc->ch[i] = (struct complexd *) malloc(chan_desc->channel_length * sizeof(struct complexd)); for (int i = 0; ichF[i] = (struct complexd *) malloc(1200 * sizeof(struct complexd)); + chan_desc->chF[i] = (struct complexd *) malloc((2+(275*12)) * sizeof(struct complexd)); for (int i = 0; inb_taps; i++) chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd)); - chan_desc->R_sqrt = (struct complexd **) malloc(6*sizeof(struct complexd **)); + chan_desc->R_sqrt = (struct complexd **) malloc(tdl_pathsby3*sizeof(struct complexd **)); if (nb_tx==2 && nb_rx==2) { for (int i = 0; i<(tdl_pathsby3); i++) @@ -1708,10 +1708,9 @@ void set_channeldesc_name(channel_desc_t *cdesc,char *modelname) { int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { double s; int i,k,l,aarx,aatx; - struct complexd anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX]; + struct complexd anew[desc->nb_tx*desc->nb_rx]; + struct complexd acorr[desc->nb_tx*desc->nb_rx]; struct complexd phase, alpha, beta; - AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX, - "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); start_meas(&desc->random_channel); for (i=0; i<(int)desc->nb_taps; i++) { @@ -1735,7 +1734,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } #ifdef DEBUG_CH - printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].x,anew[aarx+(aatx*desc->nb_rx)].y,desc->aoa,desc->ricean_factor,phase.x,phase.y); + printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].r,anew[aarx+(aatx*desc->nb_rx)].i,desc->aoa,desc->ricean_factor,phase.r,phase.i); #endif } //aatx } //aarx @@ -1752,6 +1751,11 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { */ //apply correlation matrix //compute acorr = R_sqrt[i] * anew + bzero(acorr,desc->nb_tx*desc->nb_rx*sizeof(struct complexd)); + cblas_zaxpy(desc->nb_tx*desc->nb_rx, (void *) desc->R_sqrt[i/3], (void *) anew, 1, (void *) acorr, 1); + + /* + FIXME: Function cblas_zgemv has an undefined output (for the same input) after a second call in RHEL8 (acorr = nan) alpha.r = 1.0; alpha.i = 0.0; beta.r = 0.0; @@ -1759,6 +1763,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { cblas_zgemv(CblasRowMajor, CblasNoTrans, desc->nb_tx*desc->nb_rx, desc->nb_tx*desc->nb_rx, (void *) &alpha, (void *) desc->R_sqrt[i/3], desc->nb_rx*desc->nb_tx, (void *) anew, 1, (void *) &beta, (void *) acorr, 1); + */ /* for (aarx=0;aarxnb_rx;aarx++) { @@ -1827,7 +1832,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } //nb_taps #ifdef DEBUG_CH - printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y); + printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].r,desc->ch[aarx+(aatx*desc->nb_rx)][k].i); #endif } //channel_length } diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 4b3ac5f862..ce470fe0b0 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -477,8 +477,8 @@ int gauss(unsigned int *gauss_LUT,unsigned char Nbits); double gaussdouble(double,double); void randominit(unsigned int seed_init); double uniformrandom(void); -int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples); -int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples); +int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples,int scs); +int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs); uint8_t multipath_channel_nosigconv(channel_desc_t *desc); void multipath_tv_channel(channel_desc_t *desc, double **tx_sig_re, diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index ecf5307dc0..8238b7961a 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -307,7 +307,7 @@ typedef struct f1ap_initial_ul_rrc_message_s { uint16_t crnti; uint8_t *rrc_container; int rrc_container_length; - char du2cu_rrc_container[100]; + char du2cu_rrc_container[200]; int du2cu_rrc_container_length; } f1ap_initial_ul_rrc_message_t; diff --git a/openair2/COMMON/gtpv1_u_messages_def.h b/openair2/COMMON/gtpv1_u_messages_def.h index e5ce496701..2835d07e4a 100644 --- a/openair2/COMMON/gtpv1_u_messages_def.h +++ b/openair2/COMMON/gtpv1_u_messages_def.h @@ -29,9 +29,8 @@ MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_dat MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_ind_t,Gtpv1uDataForwardingInd) MESSAGE_DEF(GTPV1U_ENB_END_MARKER_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_req_t, Gtpv1uEndMarkerReq) MESSAGE_DEF(GTPV1U_ENB_END_MARKER_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_ind_t, Gtpv1uEndMarkerInd) -MESSAGE_DEF(GTPV1U_ENB_S1_REQ, MESSAGE_PRIORITY_MED, Gtpv1uS1Req, gtpv1uS1Req) +MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq) MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_req_t, NRGtpv1uDeleteTunnelReq) MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_resp_t, NRGtpv1uDeleteTunnelResp) -MESSAGE_DEF(GTPV1U_GNB_NG_REQ, MESSAGE_PRIORITY_MED, Gtpv1uNGReq, gtpv1uNGReq) MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq) diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h index 1dff6b89cb..2dd476ab68 100644 --- a/openair2/COMMON/gtpv1_u_messages_types.h +++ b/openair2/COMMON/gtpv1_u_messages_types.h @@ -39,11 +39,10 @@ #define GTPV1U_ENB_END_MARKER_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uEndMarkerReq #define GTPV1U_ENB_END_MARKER_IND(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uEndMarkerInd -#define GTPV1U_ENB_S1_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uS1Req +#define GTPV1U_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uReq #define GTPV1U_GNB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelReq #define GTPV1U_GNB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelResp -#define GTPV1U_GNB_NG_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uNGReq #define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq #define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF @@ -174,18 +173,13 @@ typedef struct gtpv1u_enb_end_marker_ind_s { } gtpv1u_enb_end_marker_ind_t; typedef struct { - in_addr_t enb_ip_address_for_S1u_S12_S4_up; - tcp_udp_port_t enb_port_for_S1u_S12_S4_up; - char addrStr[256]; - char portStr[256]; -} Gtpv1uS1Req; + in_addr_t localAddr; + tcp_udp_port_t localPort; + char localAddrStr[256]; + char localPortStr[256]; +} Gtpv1uReq; + -typedef struct { - in_addr_t gnb_ip_address_for_NGu_up; - tcp_udp_port_t gnb_port_for_NGu_up; - char addrStr[256]; - char portStr[256]; -} Gtpv1uNGReq; typedef struct gtpv1u_gnb_create_tunnel_req_s { rnti_t rnti; int num_tunnels; diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index af746b9193..60d48c8284 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -369,6 +369,57 @@ typedef enum ngap_Cause_e { } ngap_Cause_t; +typedef enum ngap_Cause_radio_network_e { + NGAP_CAUSE_RADIO_NETWORK_UNSPECIFIED, + NGAP_CAUSE_RADIO_NETWORK_TXNRELOCOVERALL_EXPIRY, + NGAP_CAUSE_RADIO_NETWORK_SUCCESSFUL_HANDOVER, + NGAP_CAUSE_RADIO_NETWORK_RELEASE_DUE_TO_NGRAN_GENERATED_REASON, + NGAP_CAUSE_RADIO_NETWORK_RELEASE_DUE_TO_5GC_GENERATED_REASON, + NGAP_CAUSE_RADIO_NETWORK_HANDOVER_CANCELLED, + NGAP_CAUSE_RADIO_NETWORK_PARTIAL_HANDOVER, + NGAP_CAUSE_RADIO_NETWORK_HO_FAILURE_IN_TARGET_5GC_NGRAN_NODE_OR_TARGET_SYSTEM, + NGAP_CAUSE_RADIO_NETWORK_HO_TARGET_NOT_ALLOWED, + NGAP_CAUSE_RADIO_NETWORK_TNGRELOCOVERALL_EXPIRY, + NGAP_CAUSE_RADIO_NETWORK_TNGRELOCPREP_EXPIRY, + NGAP_CAUSE_RADIO_NETWORK_CELL_NOT_AVAILABLE, + NGAP_CAUSE_RADIO_NETWORK_UNKNOWN_TARGETID, + NGAP_CAUSE_RADIO_NETWORK_NO_RADIO_RESOURCES_AVAILABLE_IN_TARGET_CELL, + NGAP_CAUSE_RADIO_NETWORK_UNKNOWN_LOCAL_UE_NGAP_ID, + NGAP_CAUSE_RADIO_NETWORK_INCONSISTENT_REMOTE_UE_NGAP_ID, + NGAP_CAUSE_RADIO_NETWORK_HANDOVER_DESIRABLE_FOR_RADIO_REASON, + NGAP_CAUSE_RADIO_NETWORK_TIME_CRITICAL_HANDOVER, + NGAP_CAUSE_RADIO_NETWORK_RESOURCE_OPTIMISATION_HANDOVER, + NGAP_CAUSE_RADIO_NETWORK_REDUCE_LOAD_IN_SERVING_CELL, + NGAP_CAUSE_RADIO_NETWORK_USER_INACTIVITY, + NGAP_CAUSE_RADIO_NETWORK_RADIO_CONNECTION_WITH_UE_LOST, + NGAP_CAUSE_RADIO_NETWORK_RADIO_RESOURCES_NOT_AVAILABLE, + NGAP_CAUSE_RADIO_NETWORK_INVALID_QOS_COMBINATION, + NGAP_CAUSE_RADIO_NETWORK_FAILURE_IN_RADIO_INTERFACE_PROCEDURE, + NGAP_CAUSE_RADIO_NETWORK_INTERACTION_WITH_OTHER_PROCEDURE, + NGAP_CAUSE_RADIO_NETWORK_UNKNOWN_PDU_SESSION_ID, + NGAP_CAUSE_RADIO_NETWORK_UNKOWN_QOS_FLOW_ID, + NGAP_CAUSE_RADIO_NETWORK_MULTIPLE_PDU_SESSION_ID_INSTANCES, + NGAP_CAUSE_RADIO_NETWORK_MULTIPLE_QOS_FLOW_ID_INSTANCES, + NGAP_CAUSE_RADIO_NETWORK_ENCRYPTION_AND_OR_INTEGRITY_PROTECTION_ALGORITHMS_NOT_SUPPORTED, + NGAP_CAUSE_RADIO_NETWORK_NG_INTRA_SYSTEM_HANDOVER_TRIGGERED, + NGAP_CAUSE_RADIO_NETWORK_NG_INTER_SYSTEM_HANDOVER_TRIGGERED, + NGAP_CAUSE_RADIO_NETWORK_XN_HANDOVER_TRIGGERED, + NGAP_CAUSE_RADIO_NETWORK_NOT_SUPPORTED_5QI_VALUE, + NGAP_CAUSE_RADIO_NETWORK_UE_CONTEXT_TRANSFER, + NGAP_CAUSE_RADIO_NETWORK_IMS_VOICE_EPS_FALLBACK_OR_RAT_FALLBACK_TRIGGERED, + NGAP_CAUSE_RADIO_NETWORK_UP_INTEGRITY_PROTECTION_NOT_POSSIBLE, + NGAP_CAUSE_RADIO_NETWORK_UP_CONFIDENTIALITY_PROTECTION_NOT_POSSIBLE, + NGAP_CAUSE_RADIO_NETWORK_SLICE_NOT_SUPPORTED, + NGAP_CAUSE_RADIO_NETWORK_UE_IN_RRC_INACTIVE_STATE_NOT_REACHABLE, + NGAP_CAUSE_RADIO_NETWORK_REDIRECTION, + NGAP_CAUSE_RADIO_NETWORK_RESOURCES_NOT_AVAILABLE_FOR_THE_SLICE, + NGAP_CAUSE_RADIO_NETWORK_UE_MAX_INTEGRITY_PROTECTED_DATA_RATE_REASON, + NGAP_CAUSE_RADIO_NETWORK_RELEASE_DUE_TO_CN_DETECTED_MOBILITY, + NGAP_CAUSE_RADIO_NETWORK_N26_INTERFACE_NOT_AVAILABLE, + NGAP_CAUSE_RADIO_NETWORK_RELEASE_DUE_TO_PRE_EMPTION, + NGAP_CAUSE_RADIO_NETWORK_MULTIPLE_LOCATION_REPORTING_REFERENCE_ID_INSTANCES +} ngap_Cause_radio_network_t; + typedef struct pdusession_failed_s { /* Unique pdusession_id for the UE. */ uint8_t pdusession_id; diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 6d48de166e..41dbb26cc1 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -413,6 +413,7 @@ typedef struct NRRrcConfigurationReq_s { int sib1_tda; int pdsch_AntennaPorts; int pusch_AntennaPorts; + int minRXTXTIMEpdsch; int do_CSIRS; int pusch_TargetSNRx10; int pucch_TargetSNRx10; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 7b82ec31a1..a08bcf4baf 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2074,12 +2074,12 @@ int RCconfig_gtpu(void ) { if (address) { MessageDef *message; - AssertFatal((message = itti_alloc_new_message(TASK_ENB_APP, 0, GTPV1U_ENB_S1_REQ))!=NULL,""); - IPV4_STR_ADDR_TO_INT_NWBO ( address, GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up); - GTPV1U_ENB_S1_REQ(message).enb_port_for_S1u_S12_S4_up = enb_port_for_S1U; - strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address); - sprintf(GTPV1U_ENB_S1_REQ(message).portStr,"%d", enb_port_for_S1U); + AssertFatal((message = itti_alloc_new_message(TASK_ENB_APP, 0, GTPV1U_REQ))!=NULL,""); + IPV4_STR_ADDR_TO_INT_NWBO ( address, GTPV1U_REQ(message).localAddr, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); + LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_REQ(message).localAddr); + GTPV1U_REQ(message).localPort = enb_port_for_S1U; + strcpy(GTPV1U_REQ(message).localAddrStr,address); + sprintf(GTPV1U_REQ(message).localPortStr,"%d", enb_port_for_S1U); itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) } else LOG_E(GTPU,"invalid address for S1U\n"); diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 79e66881b5..22af2a6de0 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -156,7 +156,7 @@ typedef enum { {CONFIG_STRING_RU_SDR_ADDRS, NULL, 0, strptr:NULL, defstrval:"type=b200", TYPE_STRING, 0}, \ {CONFIG_STRING_RU_SDR_CLK_SRC, NULL, 0, strptr:NULL, defstrval:"internal", TYPE_STRING, 0}, \ {CONFIG_STRING_RU_SDR_TME_SRC, NULL, 0, strptr:NULL, defstrval:"internal", TYPE_STRING, 0}, \ - {CONFIG_STRING_RU_SF_EXTENSION, NULL, 0, uptr:NULL, defuintval:312, TYPE_UINT, 0}, \ + {CONFIG_STRING_RU_SF_EXTENSION, NULL, 0, uptr:NULL, defuintval:320, TYPE_UINT, 0}, \ {CONFIG_STRING_RU_END_OF_BURST_DELAY, NULL, 0, uptr:NULL, defuintval:400, TYPE_UINT, 0}, \ {CONFIG_STRING_RU_OTA_SYNC_ENABLE, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {CONFIG_STRING_RU_BF_WEIGHTS_LIST, NULL, 0, iptr:NULL, defintarrayval:DEFBFW, TYPE_INTARRAY, 0}, \ diff --git a/openair2/F1AP/dummy_enb.c b/openair2/F1AP/dummy_enb.c index cf7527d1f5..d54f9b8df7 100644 --- a/openair2/F1AP/dummy_enb.c +++ b/openair2/F1AP/dummy_enb.c @@ -32,3 +32,16 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, abort(); } +boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id + ) { +abort(); +} diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index aca88b9ea7..7858cd6c32 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -55,7 +55,7 @@ #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" -#define CONFIG_STRING_MACRLC_ULSCH_MAX_SLOTS_INACTIVITY "ulsch_max_slots_inactivity" +#define CONFIG_STRING_MACRLC_ULSCH_MAX_FRAME_INACTIVITY "ulsch_max_frame_inactivity" #define CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10 "pusch_TargetSNRx10" #define CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10 "pucch_TargetSNRx10" #define CONFIG_STRING_MACRLC_PUCCHFAILURETHRES "pucch_FailureThres" @@ -83,7 +83,7 @@ {CONFIG_STRING_MACRLC_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defintval:50020, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ -{CONFIG_STRING_MACRLC_ULSCH_MAX_SLOTS_INACTIVITY, "Maximum number of slots before a UE is scheduled ULSCH due to inactivity", 0, uptr:NULL, defintval:200, TYPE_UINT, 0}, \ +{CONFIG_STRING_MACRLC_ULSCH_MAX_FRAME_INACTIVITY, NULL, 0, uptr:NULL, defintval:10, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:150, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_PUCCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ @@ -106,10 +106,10 @@ #define MACRLC_REMOTE_S_PORTC_IDX 14 #define MACRLC_LOCAL_S_PORTD_IDX 15 #define MACRLC_REMOTE_S_PORTD_IDX 16 -#define MACRLC_ULSCH_MAX_SLOTS_INACTIVITY 17 +#define MACRLC_ULSCH_MAX_FRAME_INACTIVITY 17 #define MACRLC_PUSCHTARGETSNRX10_IDX 18 #define MACRLC_PUCCHTARGETSNRX10_IDX 19 -#define MACRLC_PUCCHFAILURETHRES_IDX 20 +#define MACRLC_PUCCHFAILURETHRES_IDX 20 #define MACRLC_PUSCHFAILURETHRES_IDX 21 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 29f3c15355..08255fe422 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -549,6 +549,32 @@ void RCconfig_nr_flexran() void RCconfig_NR_L1(void) { int j; + paramdef_t GNBSParams[] = GNBSPARAMS_DESC; + ////////// Identification parameters + paramdef_t GNBParams[] = GNBPARAMS_DESC; + + paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; + + config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); + int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; + AssertFatal (num_gnbs > 0,"Failed to parse config file no gnbs %s \n",GNB_CONFIG_STRING_ACTIVE_GNBS); + + config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); + char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; + if (ulprbbl) LOG_I(NR_PHY,"PRB blacklist %s\n",ulprbbl); + char *pt = strtok(ulprbbl,","); + int prbbl[275]; + int num_prbbl=0; + memset(prbbl,0,275*sizeof(int)); + + while (pt) { + prbbl[atoi(pt)] = 1; + LOG_I(NR_PHY,"Blacklisting prb %d\n",atoi(pt)); + pt = strtok(NULL,","); + num_prbbl++; + } + + paramdef_t L1_Params[] = L1PARAMS_DESC; paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; @@ -577,6 +603,9 @@ void RCconfig_NR_L1(void) { RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); RC.gNB[j]->pusch_thres = *(L1_ParamList.paramarray[j][L1_PUSCH_DTX_THRESHOLD].uptr); + RC.gNB[j]->num_ulprbbl = num_prbbl; + LOG_I(NR_PHY,"Copying %d blacklisted PRB to L1 context\n",num_prbbl); + memcpy(RC.gNB[j]->ulprbbl,prbbl,275*sizeof(int)); if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { //sf_ahead = 2; // Need 4 subframe gap between RX and TX }else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { @@ -633,6 +662,30 @@ void RCconfig_NR_L1(void) { void RCconfig_nr_macrlc() { int j; + paramdef_t GNBSParams[] = GNBSPARAMS_DESC; + ////////// Identification parameters + paramdef_t GNBParams[] = GNBPARAMS_DESC; + + paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; + + config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); + int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; + AssertFatal (num_gnbs > 0,"Failed to parse config file no gnbs %s \n",GNB_CONFIG_STRING_ACTIVE_GNBS); + + config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); + char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; + char *pt = strtok(ulprbbl,","); + int prbbl[275]; + int num_prbbl=0; + int prb; + memset(prbbl,0,275*sizeof(int)); + while (pt) { + prb=atoi(pt); + prbbl[prb] = 1; + pt = strtok(NULL,","); + num_prbbl++; + } + paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC; paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; @@ -650,7 +703,12 @@ void RCconfig_nr_macrlc() { RC.nrmac[j]->pucch_target_snrx10 = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCHTARGETSNRX10_IDX].iptr); RC.nrmac[j]->pucch_failure_thres = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCHFAILURETHRES_IDX].iptr); RC.nrmac[j]->pusch_failure_thres = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCHFAILURETHRES_IDX].iptr); - + + LOG_I(NR_MAC,"PUSCH Target %d, PUCCH Target %d, PUCCH Failure %d, PUSCH Failure %d\n", + RC.nrmac[j]->pusch_target_snrx10, + RC.nrmac[j]->pucch_target_snrx10, + RC.nrmac[j]->pucch_failure_thres, + RC.nrmac[j]->pusch_failure_thres); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP @@ -696,7 +754,11 @@ void RCconfig_nr_macrlc() { }else { // other midhaul AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr)); } - RC.nrmac[j]->ulsch_max_slots_inactivity = *(MacRLC_ParamList.paramarray[j][MACRLC_ULSCH_MAX_SLOTS_INACTIVITY].uptr); + RC.nrmac[j]->ulsch_max_frame_inactivity = *(MacRLC_ParamList.paramarray[j][MACRLC_ULSCH_MAX_FRAME_INACTIVITY].uptr); + RC.nrmac[j]->num_ulprbbl = num_prbbl; + LOG_I(NR_MAC,"Blacklisted PRBS %d\n",num_prbbl); + memcpy(RC.nrmac[j]->ulprbbl,prbbl,275*sizeof(prbbl[0])); + }// for (j=0;j 0 LOG_E(PHY,"No %s configuration found\n", CONFIG_STRING_MACRLC_LIST); @@ -707,83 +769,86 @@ void RCconfig_nr_macrlc() { void config_security(gNB_RRC_INST *rrc) { - paramdef_t logparams_defaults[] = SECURITY_GLOBALPARAMS_DESC; - int ret = config_get(logparams_defaults, - sizeof(logparams_defaults) / sizeof(paramdef_t), + paramdef_t sec_params[] = SECURITY_GLOBALPARAMS_DESC; + int ret = config_get(sec_params, + sizeof(sec_params) / sizeof(paramdef_t), CONFIG_STRING_SECURITY); int i; if (ret < 0) { - LOG_W(RRC, "configuration file does not contain a \"security\" section, applying default parameters (no security)\n"); + LOG_W(RRC, "configuration file does not contain a \"security\" section, applying default parameters (nia2 nea0, integrity disabled for DRBs)\n"); rrc->security.ciphering_algorithms[0] = 0; /* nea0 = no ciphering */ rrc->security.ciphering_algorithms_count = 1; - rrc->security.integrity_algorithms[0] = 0; /* nia0 = no integrity */ - rrc->security.integrity_algorithms_count = 1; + rrc->security.integrity_algorithms[0] = 2; /* nia2 */ + rrc->security.integrity_algorithms[1] = 0; /* nia0 = no integrity, as a fallback (but nia2 should be supported by all UEs) */ + rrc->security.integrity_algorithms_count = 2; + rrc->security.do_drb_ciphering = 1; /* even if nea0 let's activate so that we don't generate cipheringDisabled in pdcp_Config */ + rrc->security.do_drb_integrity = 0; return; } - if (logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].numelt > 4) { + if (sec_params[SECURITY_CONFIG_CIPHERING_IDX].numelt > 4) { LOG_E(RRC, "too much ciphering algorithms in section \"security\" of the configuration file, maximum is 4\n"); exit(1); } - if (logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].numelt > 4) { + if (sec_params[SECURITY_CONFIG_INTEGRITY_IDX].numelt > 4) { LOG_E(RRC, "too much integrity algorithms in section \"security\" of the configuration file, maximum is 4\n"); exit(1); } /* get ciphering algorithms */ rrc->security.ciphering_algorithms_count = 0; - for (i = 0; i < logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].numelt; i++) { - if (!strcmp(logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea0")) { + for (i = 0; i < sec_params[SECURITY_CONFIG_CIPHERING_IDX].numelt; i++) { + if (!strcmp(sec_params[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea0")) { rrc->security.ciphering_algorithms[rrc->security.ciphering_algorithms_count] = 0; rrc->security.ciphering_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea1")) { + if (!strcmp(sec_params[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea1")) { rrc->security.ciphering_algorithms[rrc->security.ciphering_algorithms_count] = 1; rrc->security.ciphering_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea2")) { + if (!strcmp(sec_params[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea2")) { rrc->security.ciphering_algorithms[rrc->security.ciphering_algorithms_count] = 2; rrc->security.ciphering_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea3")) { + if (!strcmp(sec_params[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i], "nea3")) { rrc->security.ciphering_algorithms[rrc->security.ciphering_algorithms_count] = 3; rrc->security.ciphering_algorithms_count++; continue; } LOG_E(RRC, "unknown ciphering algorithm \"%s\" in section \"security\" of the configuration file\n", - logparams_defaults[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i]); + sec_params[SECURITY_CONFIG_CIPHERING_IDX].strlistptr[i]); exit(1); } /* get integrity algorithms */ rrc->security.integrity_algorithms_count = 0; - for (i = 0; i < logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].numelt; i++) { - if (!strcmp(logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia0")) { + for (i = 0; i < sec_params[SECURITY_CONFIG_INTEGRITY_IDX].numelt; i++) { + if (!strcmp(sec_params[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia0")) { rrc->security.integrity_algorithms[rrc->security.integrity_algorithms_count] = 0; rrc->security.integrity_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia1")) { + if (!strcmp(sec_params[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia1")) { rrc->security.integrity_algorithms[rrc->security.integrity_algorithms_count] = 1; rrc->security.integrity_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia2")) { + if (!strcmp(sec_params[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia2")) { rrc->security.integrity_algorithms[rrc->security.integrity_algorithms_count] = 2; rrc->security.integrity_algorithms_count++; continue; } - if (!strcmp(logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia3")) { + if (!strcmp(sec_params[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i], "nia3")) { rrc->security.integrity_algorithms[rrc->security.integrity_algorithms_count] = 3; rrc->security.integrity_algorithms_count++; continue; } LOG_E(RRC, "unknown integrity algorithm \"%s\" in section \"security\" of the configuration file\n", - logparams_defaults[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i]); + sec_params[SECURITY_CONFIG_INTEGRITY_IDX].strlistptr[i]); exit(1); } @@ -794,9 +859,30 @@ void config_security(gNB_RRC_INST *rrc) } if (rrc->security.integrity_algorithms_count == 0) { - LOG_W(RRC, "no preferred integrity algorithm set in configuration file, applying default parameters (no security)\n"); - rrc->security.integrity_algorithms[0] = 0; /* nia0 = no integrity */ - rrc->security.integrity_algorithms_count = 1; + LOG_W(RRC, "no preferred integrity algorithm set in configuration file, applying default parameters (nia2)\n"); + rrc->security.integrity_algorithms[0] = 2; /* nia2 */ + rrc->security.integrity_algorithms[1] = 0; /* nia0 = no integrity */ + rrc->security.integrity_algorithms_count = 2; + } + + if (!strcmp(*sec_params[SECURITY_CONFIG_DO_DRB_CIPHERING_IDX].strptr, "yes")) { + rrc->security.do_drb_ciphering = 1; + } else if (!strcmp(*sec_params[SECURITY_CONFIG_DO_DRB_CIPHERING_IDX].strptr, "no")) { + rrc->security.do_drb_ciphering = 0; + } else { + LOG_E(RRC, "in configuration file, bad drb_ciphering value '%s', only 'yes' and 'no' allowed\n", + *sec_params[SECURITY_CONFIG_DO_DRB_CIPHERING_IDX].strptr); + exit(1); + } + + if (!strcmp(*sec_params[SECURITY_CONFIG_DO_DRB_INTEGRITY_IDX].strptr, "yes")) { + rrc->security.do_drb_integrity = 1; + } else if (!strcmp(*sec_params[SECURITY_CONFIG_DO_DRB_INTEGRITY_IDX].strptr, "no")) { + rrc->security.do_drb_integrity = 0; + } else { + LOG_E(RRC, "in configuration file, bad drb_integrity value '%s', only 'yes' and 'no' allowed\n", + *sec_params[SECURITY_CONFIG_DO_DRB_INTEGRITY_IDX].strptr); + exit(1); } } @@ -1016,6 +1102,8 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_IDX].iptr; printf("pusch_AntennaPorts %d\n",*GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).pusch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr; + printf("minTXRXTIMEpdsch %d\n",*GNBParamList.paramarray[i][GNB_MINRXTXTIMEPDSCH_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).minRXTXTIMEpdsch = *GNBParamList.paramarray[i][GNB_MINRXTXTIMEPDSCH_IDX].iptr; NRRRC_CONFIGURATION_REQ (msg_p).sib1_tda = *GNBParamList.paramarray[i][GNB_SIB1_TDA_IDX].iptr; printf("Do CSI-RS %d\n",*GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).do_CSIRS = *GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr; @@ -1046,7 +1134,6 @@ int RCconfig_nr_gtpu(void ) { char *address = NULL; char *cidr = NULL; char gtpupath[MAX_OPTNAME_SIZE*2 + 8]; - uint8_t gnb_mode = 0; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; paramdef_t NETParams[] = GNBNETPARAMS_DESC; @@ -1064,44 +1151,26 @@ int RCconfig_nr_gtpu(void ) { config_get(NETParams,sizeof(NETParams)/sizeof(paramdef_t),gtpupath); - if (NETParams[0].strptr != NULL) { // SA + if (NETParams[0].strptr != NULL) LOG_I(GTPU, "SA mode \n"); - cidr = gnb_ipv4_address_for_NGU; - gnb_mode = 0; - } else {// NSA + else LOG_I(GTPU, "NSA mode \n"); - cidr = gnb_ipv4_address_for_S1U; - gnb_mode = 1; - } - - address = strtok(cidr, "/"); - - if (address) { - MessageDef *message; - - if (gnb_mode == 1) { // NSA - message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_ENB_S1_REQ); - AssertFatal(message!=NULL,""); - // IPV4_STR_ADDR_TO_INT_NWBO ( address, RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - // LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up); - IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up); - GTPV1U_ENB_S1_REQ(message).enb_port_for_S1u_S12_S4_up = gnb_port_for_S1U; - strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address); - sprintf(GTPV1U_ENB_S1_REQ(message).portStr,"%d", gnb_port_for_NGU); - } else {// TODO SA - message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_GNB_NG_REQ); - AssertFatal(message!=NULL,""); - IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_GNB_NG_REQ(message).gnb_ip_address_for_NGu_up, "BAD IP ADDRESS FORMAT FOR gNB NG_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_GNB_NG_REQ(message).gnb_ip_address_for_NGu_up); - GTPV1U_GNB_NG_REQ(message).gnb_port_for_NGu_up = gnb_port_for_NGU; - strcpy(GTPV1U_GNB_NG_REQ(message).addrStr,address); - sprintf(GTPV1U_GNB_NG_REQ(message).portStr,"%d", gnb_port_for_NGU); - } - itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) + + cidr = gnb_ipv4_address_for_S1U; + address = strtok(cidr, "/"); + + if (address) { + MessageDef *message; + message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_REQ); + AssertFatal(message!=NULL,""); + IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_REQ(message).localAddr, "BAD IP ADDRESS FORMAT FOR gNB NG_U !\n" ); + LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_REQ(message).localAddr); + GTPV1U_REQ(message).localPort = gnb_port_for_NGU; + strcpy(GTPV1U_REQ(message).localAddrStr,address); + sprintf(GTPV1U_REQ(message).localPortStr,"%d", gnb_port_for_NGU); + itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) } else - LOG_E(GTPU,"invalid address for NGU\n"); - + LOG_E(GTPU,"invalid address for NGU\n"); return 0; } @@ -1938,6 +2007,7 @@ void configure_gnb_du_mac(int inst) { rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, rrc->configuration.scc, + NULL, 0, 0, // rnti (NR_CellGroupConfig_t *)NULL diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index ccab98d63c..bf1d12825e 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -119,6 +119,9 @@ typedef enum { #define GNB_CONFIG_STRING_SIB1TDA "sib1_tda" #define GNB_CONFIG_STRING_DOCSIRS "do_CSIRS" #define GNB_CONFIG_STRING_NRCELLID "nr_cellid" +#define GNB_CONFIG_STRING_MINRXTXTIMEPDSCH "min_rxtxtime_pdsch" +#define GNB_CONFIG_STRING_ULPRBBLACKLIST "ul_prbblacklist" + /*-----------------------------------------------------------------------------------------------------------------------------------------*/ /* cell configuration parameters */ @@ -145,7 +148,9 @@ typedef enum { {GNB_CONFIG_STRING_SIB1TDA, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_DOCSIRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_NRCELLID, NULL, 0, u64ptr:NULL, defint64val:1, TYPE_UINT64, 0}, \ -} +{GNB_CONFIG_STRING_MINRXTXTIMEPDSCH, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0} \ +} #define GNB_GNB_ID_IDX 0 #define GNB_CELL_TYPE_IDX 1 @@ -167,6 +172,8 @@ typedef enum { #define GNB_SIB1_TDA_IDX 17 #define GNB_DO_CSIRS_IDX 18 #define GNB_NRCELLID_IDX 19 +#define GNB_MINRXTXTIMEPDSCH_IDX 20 +#define GNB_ULPRBBLACKLIST_IDX 21 #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define GNBPARAMS_CHECK { \ @@ -463,10 +470,12 @@ typedef enum { /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* security configuration */ /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define CONFIG_STRING_SECURITY "security" +#define CONFIG_STRING_SECURITY "security" -#define SECURITY_CONFIG_CIPHERING "ciphering_algorithms" -#define SECURITY_CONFIG_INTEGRITY "integrity_algorithms" +#define SECURITY_CONFIG_CIPHERING "ciphering_algorithms" +#define SECURITY_CONFIG_INTEGRITY "integrity_algorithms" +#define SECURITY_CONFIG_DO_DRB_CIPHERING "drb_ciphering" +#define SECURITY_CONFIG_DO_DRB_INTEGRITY "drb_integrity" /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* security configuration */ @@ -475,10 +484,15 @@ typedef enum { #define SECURITY_GLOBALPARAMS_DESC { \ {SECURITY_CONFIG_CIPHERING, "preferred ciphering algorithms\n", 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0}, \ {SECURITY_CONFIG_INTEGRITY, "preferred integrity algorithms\n", 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0}, \ + {SECURITY_CONFIG_DO_DRB_CIPHERING, "use ciphering for DRBs", 0, strptr:NULL, defstrval:"yes", TYPE_STRING, 0}, \ + {SECURITY_CONFIG_DO_DRB_INTEGRITY, "use integrity for DRBs", 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ } -#define SECURITY_CONFIG_CIPHERING_IDX 0 -#define SECURITY_CONFIG_INTEGRITY_IDX 1 +#define SECURITY_CONFIG_CIPHERING_IDX 0 +#define SECURITY_CONFIG_INTEGRITY_IDX 1 +#define SECURITY_CONFIG_DO_DRB_CIPHERING_IDX 2 +#define SECURITY_CONFIG_DO_DRB_INTEGRITY_IDX 3 + /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index 996c2fbe27..4fcbd322db 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -51,7 +51,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint32_t Ninfo, Np_info, C; uint8_t n, scale; - LOG_D(MAC,"nb_symb_sch %d, nb_dmrs_prb %d, nb_rb_oh %d\n",nb_symb_sch,nb_dmrs_prb,nb_rb_oh); + LOG_D(NR_MAC,"nb_symb_sch %d, nb_dmrs_prb %d, nb_rb_oh %d\n",nb_symb_sch,nb_dmrs_prb,nb_rb_oh); nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; nb_re = min(156, nbp_re) * nb_rb; @@ -59,6 +59,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, // Intermediate number of information bits Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling; + if (Ninfo <=3824) { n = max(3, floor(log2(Ninfo)) - 6); Np_info = max(24, (Ninfo>>n)<nrofCandidates->aggregationLevel1 != NR_SearchSpace__nrofCandidates__aggregationLevel1_n0) { - *aggregation_level = 1; - *nr_of_candidates = ss->nrofCandidates->aggregationLevel1; - } - if (ss->nrofCandidates->aggregationLevel2 != NR_SearchSpace__nrofCandidates__aggregationLevel2_n0) { - *aggregation_level = 2; - *nr_of_candidates = ss->nrofCandidates->aggregationLevel2; - } - if (ss->nrofCandidates->aggregationLevel4 != NR_SearchSpace__nrofCandidates__aggregationLevel4_n0) { - *aggregation_level = 4; - *nr_of_candidates = ss->nrofCandidates->aggregationLevel4; - } - if (ss->nrofCandidates->aggregationLevel8 != NR_SearchSpace__nrofCandidates__aggregationLevel8_n0) { - *aggregation_level = 8; - *nr_of_candidates = ss->nrofCandidates->aggregationLevel8; - } - if (ss->nrofCandidates->aggregationLevel16 != NR_SearchSpace__nrofCandidates__aggregationLevel16_n0) { - *aggregation_level = 16; - *nr_of_candidates = ss->nrofCandidates->aggregationLevel16; - } - // n8 does not correspont to a value of 8 but 7, the following corrects this - if(*nr_of_candidates == 7) - *nr_of_candidates = 8; + NR_SearchSpace_t *ss, + int L) { + AssertFatal(L>=1 && L<=16,"L %d not ok\n",L); + *nr_of_candidates = 0; + switch(L) { + case 1: + if (ss->nrofCandidates->aggregationLevel1 != NR_SearchSpace__nrofCandidates__aggregationLevel1_n0) { + *aggregation_level = 1; + *nr_of_candidates = ss->nrofCandidates->aggregationLevel1; + } + break; + case 2: + if (ss->nrofCandidates->aggregationLevel2 != NR_SearchSpace__nrofCandidates__aggregationLevel2_n0) { + *aggregation_level = 2; + *nr_of_candidates = ss->nrofCandidates->aggregationLevel2; + } + break; + case 4: + if (ss->nrofCandidates->aggregationLevel4 != NR_SearchSpace__nrofCandidates__aggregationLevel4_n0) { + *aggregation_level = 4; + *nr_of_candidates = ss->nrofCandidates->aggregationLevel4; + } + break; + case 8: + if (ss->nrofCandidates->aggregationLevel8 != NR_SearchSpace__nrofCandidates__aggregationLevel8_n0) { + *aggregation_level = 8; + *nr_of_candidates = ss->nrofCandidates->aggregationLevel8; + } + break; + case 16: + if (ss->nrofCandidates->aggregationLevel16 != NR_SearchSpace__nrofCandidates__aggregationLevel16_n0) { + *aggregation_level = 16; + *nr_of_candidates = ss->nrofCandidates->aggregationLevel16; + } + break; + } } @@ -1519,7 +1556,7 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1) format2 = (uint8_t) table_6_3_3_2_3_prachConfig_Index[index][1]; *format = ((uint8_t) table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2<<8); - LOG_I(MAC,"Getting Total PRACH info from index %d (col %lu ) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", + LOG_D(NR_MAC,"Getting Total PRACH info from index %d (col %lu ) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", index, table_6_3_3_2_3_prachConfig_Index[index][6], pointa, mu, @@ -1562,60 +1599,6 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, } -uint8_t get_nr_prach_duration(uint8_t prach_format){ - - switch(prach_format){ - - case 0: // format 0 - return 0; - - case 1: // format 1 - return 0; - - case 2: // format 2 - return 0; - - case 3: // format 3 - return 0; - - case 4: // format A1 - return 2; - - case 5: // format A2 - return 4; - - case 6: // format A3 - return 6; - - case 7: // format B1 - return 2; - - case 8: // format B4 - return 12; - - case 9: // format C0 - return 2; - - case 10: // format C2 - return 6; - - case 11: // format A1/B1 - return 2; - - case 12: // format A2/B2 - return 4; - - case 13: // format A3/B3 - return 6; - - default : - AssertFatal(1==0,"Invalid Prach format\n"); - break; - - } - -} - int get_nr_prach_info_from_index(uint8_t index, int frame, int slot, @@ -1970,170 +1953,6 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = { {0, 3072, -1, -1, 3, 1539, -1, -1}, //14 // (DMRS l' position) }; -// Returns the corresponding row index of the NR table -int get_nr_table_idx(int nr_bandP, uint8_t scs_index) -{ - int i, j; - int scs_khz = 15 << scs_index; - int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; - size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); - - for(j = 0; j < s; j++){ - if (nr_bandP == supplementary_bands[j]) - AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]); - } - - AssertFatal(nr_bandP <= nr_bandtable[nr_bandtable_size-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[nr_bandtable_size-1].band); - for (i = 0; i < nr_bandtable_size && nr_bandtable[i].band != nr_bandP; i++); - - // selection of correct Deltaf raster according to SCS - if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) - i++; - - LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min); - - return i; -} - -// Computes the duplex spacing (either positive or negative) in KHz -int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index) -{ - int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index); - - int32_t delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min); - - LOG_I(PHY, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band); - - return delta_duplex; -} - -lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index) -{ - lte_frame_type_t current_type; - int32_t delta_duplex = get_delta_duplex(current_band, scs_index); - - if (delta_duplex == 0) - current_type = TDD; - else - current_type = FDD; - - LOG_I(MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[current_type], delta_duplex); - - return current_type; -} - -uint16_t config_bandwidth(int mu, int nb_rb, int nr_band) -{ - - if (nr_band < 100) { //FR1 - switch(mu) { - case 0 : - if (nb_rb<=25) - return 5; - if (nb_rb<=52) - return 10; - if (nb_rb<=79) - return 15; - if (nb_rb<=106) - return 20; - if (nb_rb<=133) - return 25; - if (nb_rb<=160) - return 30; - if (nb_rb<=216) - return 40; - if (nb_rb<=270) - return 50; - AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); - break; - case 1 : - if (nb_rb<=11) - return 5; - if (nb_rb<=24) - return 10; - if (nb_rb<=38) - return 15; - if (nb_rb<=51) - return 20; - if (nb_rb<=65) - return 25; - if (nb_rb<=78) - return 30; - if (nb_rb<=106) - return 40; - if (nb_rb<=133) - return 50; - if (nb_rb<=162) - return 60; - if (nb_rb<=189) - return 70; - if (nb_rb<=217) - return 80; - if (nb_rb<=245) - return 90; - if (nb_rb<=273) - return 100; - AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); - break; - case 2 : - if (nb_rb<=11) - return 10; - if (nb_rb<=18) - return 15; - if (nb_rb<=24) - return 20; - if (nb_rb<=31) - return 25; - if (nb_rb<=38) - return 30; - if (nb_rb<=51) - return 40; - if (nb_rb<=65) - return 50; - if (nb_rb<=79) - return 60; - if (nb_rb<=93) - return 70; - if (nb_rb<=107) - return 80; - if (nb_rb<=121) - return 90; - if (nb_rb<=135) - return 100; - AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); - break; - default: - AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band); - } - } - else { - switch(mu) { - case 2 : - if (nb_rb<=66) - return 50; - if (nb_rb<=132) - return 100; - if (nb_rb<=264) - return 200; - AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); - break; - case 3 : - if (nb_rb<=32) - return 50; - if (nb_rb<=66) - return 100; - if (nb_rb<=132) - return 200; - if (nb_rb<=264) - return 400; - AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band); - break; - default: - AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band); - } - } - -} void get_delta_arfcn(int i, uint32_t nrarfcn, uint64_t N_OFFs){ @@ -2154,7 +1973,7 @@ uint32_t to_nrarfcn(int nr_bandP, uint32_t nrarfcn; int i = get_nr_table_idx(nr_bandP, scs_index); - LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw); + LOG_I(NR_MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw); AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min, "Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n", @@ -2231,14 +2050,14 @@ uint64_t from_nrarfcn(int nr_bandP, } } - LOG_D(MAC, "Frequency from NR-ARFCN for N_OFFs %lu, duplex spacing %d KHz, deltaFglobal %d KHz\n", N_OFFs, delta_duplex, deltaFglobal); + LOG_D(NR_MAC, "Frequency from NR-ARFCN for N_OFFs %lu, duplex spacing %d KHz, deltaFglobal %d KHz\n", N_OFFs, delta_duplex, deltaFglobal); AssertFatal(nrarfcn >= N_OFFs,"nrarfcn %u < N_OFFs[%d] %llu\n", nrarfcn, nr_bandtable[i].band, (long long unsigned int)N_OFFs); get_delta_arfcn(i, nrarfcn, N_OFFs); frequency = 1000*(F_REF_Offs_khz + (nrarfcn - N_REF_Offs) * deltaFglobal); - LOG_I(MAC, "Computing frequency (pointA %llu => %llu KHz (freq_min %llu KHz, NR band %d N_OFFs %llu))\n", + LOG_I(NR_MAC, "Computing frequency (pointA %llu => %llu KHz (freq_min %llu KHz, NR band %d N_OFFs %llu))\n", (unsigned long long)nrarfcn, (unsigned long long)frequency/1000, (unsigned long long)freq_min, @@ -2505,13 +2324,7 @@ static inline uint8_t get_table_idx(uint8_t mcs_table, uint8_t dci_format, uint8 return 1; } -int get_num_dmrs(uint16_t dmrs_mask ) { - int num_dmrs=0; - - for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1); - return(num_dmrs); -} /* returns the total DMRS symbols in a slot*/ uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols, int startSymbol, int mappingtype){ return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols, startSymbol, mappingtype)); @@ -2583,7 +2396,7 @@ int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmr uint8_t row, colomn; int32_t l_prime; - LOG_D(MAC, "PUSCH: NrofSymbols:%d, startSymbol:%d, mappingtype:%d, dmrs_TypeA_Position:%d\n", duration_in_symbols, start_symbol, mapping_type, dmrs_typeA_position); + LOG_D(NR_MAC, "PUSCH: NrofSymbols:%d, startSymbol:%d, mappingtype:%d, dmrs_TypeA_Position:%d\n", duration_in_symbols, start_symbol, mapping_type, dmrs_typeA_position); // Section 6.4.1.1.3 in Spec 38.211 // For PDSCH Mapping TypeA, ld is duration between first OFDM of the slot and last OFDM symbol of the scheduled PUSCH resources @@ -2610,7 +2423,7 @@ int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmr l0 = 1<=0,"invalid l_prime < 0\n"); l_prime = (mapping_type == typeA) ? (l_prime | l0) : (l_prime << start_symbol); @@ -2653,7 +2466,7 @@ uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint else if (I_mcs >= mcs3 && I_mcs < mcs4) return 0; else { - LOG_I(PHY, "PT-RS time-density determination is obtained from the DCI for the same transport block in the initial transmission\n"); + LOG_D(NR_MAC, "PT-RS time-density determination is obtained from the DCI for the same transport block in the initial transmission\n"); return -1; } } @@ -2686,22 +2499,22 @@ uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB) { // - "UE procedure for applying transform precoding on PUSCH" uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_PUSCH_Config_t *pusch_config, - const NR_BWP_Uplink_t *ubwp, + const NR_BWP_UplinkDedicated_t *ubwp, uint8_t *dci_format, int rnti_type, uint8_t configuredGrant){ if (configuredGrant) { - if (ubwp->bwp_Dedicated->configuredGrantConfig) { - if (ubwp->bwp_Dedicated->configuredGrantConfig->choice.setup->transformPrecoder) { - return *ubwp->bwp_Dedicated->configuredGrantConfig->choice.setup->transformPrecoder; + if (ubwp->configuredGrantConfig) { + if (ubwp->configuredGrantConfig->choice.setup->transformPrecoder) { + return *ubwp->configuredGrantConfig->choice.setup->transformPrecoder; } } } if (rnti_type != NR_RNTI_RA && rnti_type != NR_RNTI_TC) { if (*dci_format != NR_UL_DCI_FORMAT_0_0) { - if (pusch_config->transformPrecoder != NULL) { + if (pusch_config && pusch_config->transformPrecoder != NULL) { return *pusch_config->transformPrecoder; } } @@ -2718,7 +2531,8 @@ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, return -1; } -uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, +uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, + const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, @@ -2732,27 +2546,47 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, int num_entries = 0; int pusch_antenna_ports = 1; // TODO hardcoded number of antenna ports for pusch - NR_BWP_Downlink_t *bwp = NULL; - NR_BWP_Uplink_t *ubwp = NULL; - NR_PDSCH_Config_t *pdsch_config = NULL; - NR_PUSCH_Config_t *pusch_Config = NULL; - NR_SRS_Config_t *srs_config = NULL; + const NR_BWP_DownlinkDedicated_t *bwpd = NULL; + const NR_BWP_UplinkDedicated_t *ubwpd = NULL; + const NR_BWP_DownlinkCommon_t *bwpc = NULL; + const NR_BWP_UplinkCommon_t *ubwpc = NULL; + const NR_PDSCH_Config_t *pdsch_Config = NULL; + const NR_PUSCH_Config_t *pusch_Config = NULL; + const NR_PUCCH_Config_t *pucch_Config = NULL; + const NR_PDCCH_Config_t *pdcch_Config = NULL; + const NR_SRS_Config_t *srs_config = NULL; if(bwp_id > 0) { AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); - bwp=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - ubwp=cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]; - pdsch_config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; - pusch_Config = ubwp->bwp_Dedicated->pusch_Config->choice.setup; - srs_config = ubwp->bwp_Dedicated->srs_Config->choice.setup; + bwpd=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + bwpc=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common; + ubwpd=cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + ubwpc=cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common; + pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; + pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; + pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; + pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; + srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; + } + else if (cg){ + bwpd=cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + bwpc=initialDownlinkBWP; + ubwpd=cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + ubwpc=initialUplinkBWP; + pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; + pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; + pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; + pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; + srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; } + int n_ul_bwp=1,n_dl_bwp=1; switch(format) { /*Only sizes for 0_0 and 1_0 are correct at the moment*/ case NR_UL_DCI_FORMAT_0_0: /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 size += 20; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated - size += nr_dci_size(initialUplinkBWP,cg,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id) - size; // Padding to match 1_0 size + size += nr_dci_size(initialDownlinkBWP,initialUplinkBWP,cg,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id) - size; // Padding to match 1_0 size // UL/SUL indicator assumed to be 0 break; @@ -2770,56 +2604,71 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, size += dci_pdu->ul_sul_indicator.nbits; } // BWP Indicator - uint8_t n_ul_bwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + n_ul_bwp = 0; + if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) + n_ul_bwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; if (n_ul_bwp < 2) dci_pdu->bwp_indicator.nbits = n_ul_bwp; else dci_pdu->bwp_indicator.nbits = 2; size += dci_pdu->bwp_indicator.nbits; // Freq domain assignment - if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup->rbg_Size != NULL) - rbg_size_config = 1; - else - rbg_size_config = 0; - numRBG = getNRBG(NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - rbg_size_config); - if (pusch_Config->resourceAllocation == 0) - dci_pdu->frequency_domain_assignment.nbits = numRBG; - else if (pusch_Config->resourceAllocation == 1) - dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); - else - dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; + if (pusch_Config) { + if (pusch_Config->rbg_Size != NULL) + rbg_size_config = 1; + else + rbg_size_config = 0; + numRBG = getNRBG(NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), + NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), + rbg_size_config); + if (pusch_Config->resourceAllocation == 0) + dci_pdu->frequency_domain_assignment.nbits = numRBG; + else if (pusch_Config->resourceAllocation == 1) + dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + else + dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; + } + else dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment - if (pusch_Config->pusch_TimeDomainAllocationList==NULL) { - if (ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList==NULL) + if (pusch_Config==NULL || pusch_Config->pusch_TimeDomainAllocationList==NULL) { + if (ubwpc->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList==NULL) num_entries = 16; // num of entries in default table else - num_entries = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count; + num_entries = ubwpc->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count; } else num_entries = pusch_Config->pusch_TimeDomainAllocationList->choice.setup->list.count; dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); + LOG_D(NR_MAC,"PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n",dci_pdu->time_domain_assignment.nbits,pusch_Config); size += dci_pdu->time_domain_assignment.nbits; // Frequency Hopping flag - if ((pusch_Config->frequencyHopping!=NULL) && (pusch_Config->resourceAllocation != NR_PUSCH_Config__resourceAllocation_resourceAllocationType0)) { + if (pusch_Config && + pusch_Config->frequencyHopping!=NULL && + pusch_Config->resourceAllocation != NR_PUSCH_Config__resourceAllocation_resourceAllocationType0) { dci_pdu->frequency_hopping_flag.nbits = 1; size += 1; } // 1st DAI - if (cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook==NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) + if (cg->physicalCellGroupConfig && + cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook==NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) dci_pdu->dai[0].nbits = 2; else dci_pdu->dai[0].nbits = 1; size += dci_pdu->dai[0].nbits; + LOG_D(NR_MAC,"DAI1 nbits %d\n",dci_pdu->dai[0].nbits); // 2nd DAI - if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { //TODO not sure about that + if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && + cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { //TODO not sure about that dci_pdu->dai[1].nbits = 2; size += dci_pdu->dai[1].nbits; } // SRS resource indicator - if (pusch_Config->txConfig != NULL){ + if (srs_config && + pusch_Config && + pusch_Config->txConfig != NULL){ int count=0; if (*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook){ for (int i=0; isrs_ResourceSetToAddModList->list.count; i++) { @@ -2834,7 +2683,8 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, else { int lmin,Lmax = 0; int lsum = 0; - if ( cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig != NULL) { + if ( cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig != NULL) { if ( cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers != NULL) Lmax = *cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; else @@ -2854,11 +2704,13 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, dci_pdu->srs_resource_indicator.nbits = (int)ceil(log2(lsum)); size += dci_pdu->srs_resource_indicator.nbits; } - } + } else dci_pdu->srs_resource_indicator.nbits = 0; + LOG_D(NR_MAC,"dci_pdu->srs_resource_indicator.nbits %d\n",dci_pdu->srs_resource_indicator.nbits); // Precoding info and number of layers - long transformPrecoder = get_transformPrecoding(initialUplinkBWP, pusch_Config, ubwp, (uint8_t*)&format, rnti_type, 0); - - if (pusch_Config->txConfig != NULL){ + long transformPrecoder = get_transformPrecoding(initialUplinkBWP, pusch_Config, ubwpd, (uint8_t*)&format, rnti_type, 0); + dci_pdu->precoding_information.nbits=0; + if (pusch_Config && + pusch_Config->txConfig != NULL){ if (*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook){ if (pusch_antenna_ports > 1) { if (pusch_antenna_ports == 4) { @@ -2882,15 +2734,18 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, } } size += dci_pdu->precoding_information.nbits; + LOG_D(NR_MAC,"dci_pdu->precoding_informaiton.nbits=%d\n",dci_pdu->precoding_information.nbits); // Antenna ports NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = NULL; int xa=0; int xb=0; - if(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL){ + if(pusch_Config && + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL){ NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup; xa = ul_ant_bits(NR_DMRS_UplinkConfig,transformPrecoder); } - if(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL){ + if(pusch_Config && + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL){ NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; xb = ul_ant_bits(NR_DMRS_UplinkConfig,transformPrecoder); } @@ -2899,6 +2754,7 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, else dci_pdu->antenna_ports.nbits = xb; size += dci_pdu->antenna_ports.nbits; + LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits = %d\n",dci_pdu->antenna_ports.nbits); // SRS request if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL) dci_pdu->srs_request.nbits = 2; @@ -2913,20 +2769,26 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, } } // CBGTI - if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { + if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { int num = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock; dci_pdu->cbgti.nbits = 2 + (num<<1); size += dci_pdu->cbgti.nbits; } // PTRS - DMRS association - if ( (NR_DMRS_UplinkConfig->phaseTrackingRS == NULL && transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) || - transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled || (*pusch_Config->maxRank==1) ) + if ( (NR_DMRS_UplinkConfig && + NR_DMRS_UplinkConfig->phaseTrackingRS == NULL && + transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) || + transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled || + (pusch_Config && pusch_Config->maxRank && + *pusch_Config->maxRank==1) ) dci_pdu->ptrs_dmrs_association.nbits = 0; else dci_pdu->ptrs_dmrs_association.nbits = 2; size += dci_pdu->ptrs_dmrs_association.nbits; // beta offset indicator - if (pusch_Config->uci_OnPUSCH!=NULL){ + if (pusch_Config && + pusch_Config->uci_OnPUSCH!=NULL){ if (pusch_Config->uci_OnPUSCH->choice.setup->betaOffsets->present == NR_UCI_OnPUSCH__betaOffsets_PR_dynamic) { dci_pdu->beta_offset_indicator.nbits = 2; size += dci_pdu->beta_offset_indicator.nbits; @@ -2950,6 +2812,7 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, break; case NR_DL_DCI_FORMAT_1_1: + LOG_D(NR_MAC,"DCI_FORMAT 1_1 : pdsch_Config %p, pucch_Config %p\n",pdsch_Config,pucch_Config); // General note: 0 bits condition is ignored as default nbits is 0. // Format identifier size = 1; @@ -2958,89 +2821,105 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, dci_pdu->carrier_indicator.nbits=3; size += dci_pdu->carrier_indicator.nbits; } + // BWP Indicator - uint8_t n_dl_bwp = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; + n_dl_bwp = 0; + if (cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) + n_dl_bwp = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; if (n_dl_bwp < 2) dci_pdu->bwp_indicator.nbits = n_dl_bwp; else dci_pdu->bwp_indicator.nbits = 2; size += dci_pdu->bwp_indicator.nbits; // Freq domain assignment - rbg_size_config = cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size; - numRBG = getNRBG(NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), + if (pdsch_Config) rbg_size_config = pdsch_Config->rbg_Size; + else rbg_size_config = 0; + + numRBG = getNRBG(NRRIV2BW(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), + NRRIV2PRBOFFSET(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), rbg_size_config); - if (pdsch_config->resourceAllocation == 0) - dci_pdu->frequency_domain_assignment.nbits = numRBG; - else if (pdsch_config->resourceAllocation == 1) - dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + if (pdsch_Config && pdsch_Config->resourceAllocation == 0) + dci_pdu->frequency_domain_assignment.nbits = numRBG; + else if (pdsch_Config == NULL || pdsch_Config->resourceAllocation == 1) + dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); else - dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; + dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; size += dci_pdu->frequency_domain_assignment.nbits; + LOG_D(NR_MAC,"dci_pdu->frequency_domain_assignment.nbits %d (N_RB %d)\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); // Time domain assignment (see table 5.1.2.1.1-1 in 38.214 - if (pdsch_config->pdsch_TimeDomainAllocationList==NULL) { - if (bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList==NULL) + if (pdsch_Config == NULL || pdsch_Config->pdsch_TimeDomainAllocationList==NULL) { + if (bwpc->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList==NULL) num_entries = 16; // num of entries in default table else - num_entries = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; + num_entries = bwpc->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; } else - num_entries = pdsch_config->pdsch_TimeDomainAllocationList->choice.setup->list.count; + num_entries = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup->list.count; dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); + LOG_D(NR_MAC,"pdsch tda.nbits= %d\n",dci_pdu->time_domain_assignment.nbits); size += dci_pdu->time_domain_assignment.nbits; // VRB to PRB mapping - if ((pdsch_config->resourceAllocation == 1) && (bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver != NULL)) { + if (pdsch_Config && + pdsch_Config->resourceAllocation == 1 && + pdsch_Config->vrb_ToPRB_Interleaver != NULL) { dci_pdu->vrb_to_prb_mapping.nbits = 1; size += dci_pdu->vrb_to_prb_mapping.nbits; } // PRB bundling size indicator - if (pdsch_config->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling) { + if (pdsch_Config && + pdsch_Config->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling) { dci_pdu->prb_bundling_size_indicator.nbits = 1; size += dci_pdu->prb_bundling_size_indicator.nbits; } // Rate matching indicator - NR_RateMatchPatternGroup_t *group1 = pdsch_config->rateMatchPatternGroup1; - NR_RateMatchPatternGroup_t *group2 = pdsch_config->rateMatchPatternGroup2; + NR_RateMatchPatternGroup_t *group1 = pdsch_Config ? pdsch_Config->rateMatchPatternGroup1 : NULL; + NR_RateMatchPatternGroup_t *group2 = pdsch_Config ? pdsch_Config->rateMatchPatternGroup2 : NULL; if ((group1 != NULL) && (group2 != NULL)) dci_pdu->rate_matching_indicator.nbits = 2; if ((group1 != NULL) != (group2 != NULL)) dci_pdu->rate_matching_indicator.nbits = 1; size += dci_pdu->rate_matching_indicator.nbits; // ZP CSI-RS trigger - if (pdsch_config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) { - uint8_t nZP = pdsch_config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList->list.count; + if (pdsch_Config && + pdsch_Config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) { + uint8_t nZP = pdsch_Config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList->list.count; dci_pdu->zp_csi_rs_trigger.nbits = (int)ceil(log2(nZP+1)); } size += dci_pdu->zp_csi_rs_trigger.nbits; // TB1- MCS 5, NDI 1, RV 2 size += 8; // TB2 - long *maxCWperDCI = pdsch_config->maxNrofCodeWordsScheduledByDCI; + long *maxCWperDCI = pdsch_Config ? pdsch_Config->maxNrofCodeWordsScheduledByDCI : NULL; if ((maxCWperDCI != NULL) && (*maxCWperDCI == 2)) { size += 8; } // HARQ PID size += 4; // DAI - if (cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell + if (cg->physicalCellGroupConfig && + cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell dci_pdu->dai[0].nbits = 2; size += dci_pdu->dai[0].nbits; } + LOG_D(NR_MAC,"dci_pdu->dai[0].nbits %d\n",dci_pdu->dai[0].nbits); // TPC PUCCH size += 2; // PUCCH resource indicator size += 3; // PDSCH to HARQ timing indicator - uint8_t I = ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.count; + uint8_t I = pucch_Config->dl_DataToUL_ACK ? pucch_Config->dl_DataToUL_ACK->list.count : 8; dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits = (int)ceil(log2(I)); size += dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits; + LOG_D(NR_MAC,"dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits %d\n",dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits); // Antenna ports - NR_SetupRelease_DMRS_DownlinkConfig_t *typeA = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA; - NR_SetupRelease_DMRS_DownlinkConfig_t *typeB = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB; + NR_SetupRelease_DMRS_DownlinkConfig_t *typeA = pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA : NULL; + NR_SetupRelease_DMRS_DownlinkConfig_t *typeB = pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB : NULL; + AssertFatal(typeA!=NULL || typeB!=NULL, "either dmrs_typeA or typeB must be configured\n"); dci_pdu->antenna_ports.nbits = getAntPortBitWidth(typeA,typeB); size += dci_pdu->antenna_ports.nbits; + LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits %d\n",dci_pdu->antenna_ports.nbits); // Tx Config Indication - long *isTciEnable = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]->tci_PresentInDCI; + long *isTciEnable = pdcch_Config->controlResourceSetToAddModList->list.array[0]->tci_PresentInDCI; if (isTciEnable != NULL) { dci_pdu->transmission_configuration_indication.nbits = 3; size += dci_pdu->transmission_configuration_indication.nbits; @@ -3052,9 +2931,10 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialUplinkBWP, dci_pdu->srs_request.nbits = 3; size += dci_pdu->srs_request.nbits; // CBGTI - if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { + if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig&& + cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { uint8_t maxCBGperTB = (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock + 1) * 2; - long *maxCWperDCI_rrc = pdsch_config->maxNrofCodeWordsScheduledByDCI; + long *maxCWperDCI_rrc = pdsch_Config->maxNrofCodeWordsScheduledByDCI; uint8_t maxCW = (maxCWperDCI_rrc == NULL) ? 1 : *maxCWperDCI_rrc; dci_pdu->cbgti.nbits = maxCBGperTB * maxCW; size += dci_pdu->cbgti.nbits; @@ -3528,13 +3408,23 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD uint16_t ssb_start_symbol, NR_SubcarrierSpacing_t scs_ssb, frequency_range_t frequency_range, + int nr_band, uint32_t ssb_index, uint32_t ssb_period, uint32_t ssb_offset_point_a) { NR_SubcarrierSpacing_t scs_pdcch; - channel_bandwidth_t min_channel_bw = bw_10MHz; // TODO remove hardcoding and implement Table 5.3.5-1 in 38.104 + channel_bandwidth_t min_channel_bw; + + // according to Table 5.3.5-1 in 38.104 + // band 79 is the only one which minimum is 40 + // for all the other channels it is either 10 or 5 + // and there is no difference between the two for this implementation so it is set it to 10 + if (nr_band == 79) + min_channel_bw = bw_40MHz; + else + min_channel_bw = bw_10MHz; if (frequency_range == FR2) { if(mib->subCarrierSpacingCommon == NR_MIB__subCarrierSpacingCommon_scs15or60) @@ -3562,9 +3452,10 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD type0_PDCCH_CSS_config->num_rbs = -1; type0_PDCCH_CSS_config->num_symbols = -1; type0_PDCCH_CSS_config->rb_offset = -1; + LOG_D(NR_MAC,"NR_SubcarrierSpacing_kHz30 %d, scs_ssb %d, scs_pdcch %d, min_chan_bw %d\n",(int)NR_SubcarrierSpacing_kHz30,(int)scs_ssb,(int)scs_pdcch,min_channel_bw); // type0-pdcch coreset - switch( (scs_ssb << 3) | scs_pdcch ){ + switch( ((int)scs_ssb << 3) | (int)scs_pdcch ){ case (NR_SubcarrierSpacing_kHz15 << 5) | NR_SubcarrierSpacing_kHz15: AssertFatal(index_4msb < 15, "38.213 Table 13-1 4 MSB out of range\n"); type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern = 1; @@ -3597,7 +3488,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD }else{ ; } break; - + case (NR_SubcarrierSpacing_kHz30 << 3) | NR_SubcarrierSpacing_kHz30: if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){ type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern = 1; @@ -3674,13 +3565,14 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD break; default: + LOG_E(NR_MAC,"NR_SubcarrierSpacing_kHz30 %d, scs_ssb %d, scs_pdcch %d, min_chan_bw %d\n",NR_SubcarrierSpacing_kHz30,(int)scs_ssb,(int)scs_pdcch,min_channel_bw); break; } - LOG_D(MAC,"Coreset0: index_4msb=%d, num_rbs=%d, num_symb=%d, rb_offset=%d\n", + LOG_D(NR_MAC,"Coreset0: index_4msb=%d, num_rbs=%d, num_symb=%d, rb_offset=%d\n", index_4msb,type0_PDCCH_CSS_config->num_rbs,type0_PDCCH_CSS_config->num_symbols,type0_PDCCH_CSS_config->rb_offset ); - AssertFatal(type0_PDCCH_CSS_config->num_rbs != -1, "Type0 PDCCH coreset num_rbs undefined"); + AssertFatal(type0_PDCCH_CSS_config->num_rbs != -1, "Type0 PDCCH coreset num_rbs undefined, index_4msb=%d, min_channel_bw %d, scs_ssb %d, scs_pdcch %d\n",index_4msb,min_channel_bw,(int)scs_ssb,(int)scs_pdcch); AssertFatal(type0_PDCCH_CSS_config->num_symbols != -1, "Type0 PDCCH coreset num_symbols undefined"); AssertFatal(type0_PDCCH_CSS_config->rb_offset != -1, "Type0 PDCCH coreset rb_offset undefined"); @@ -3935,7 +3827,7 @@ void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_conf } -uint8_t fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, int L) { +void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { if(ss0 == NULL) ss0=calloc(1,sizeof(*ss0)); if(ss0->controlResourceSetId == NULL) ss0->controlResourceSetId=calloc(1,sizeof(*ss0->controlResourceSetId)); @@ -3953,7 +3845,6 @@ uint8_t fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t AssertFatal(type0_PDCCH_CSS_config!=NULL,"No type0 CSS configuration\n"); max_agg = (type0_PDCCH_CSS_config->num_symbols*type0_PDCCH_CSS_config->num_rbs)/6; - if (L>max_agg) return 0; symbols = (1-(1<num_symbols))<first_symbol_index; duration = type0_PDCCH_CSS_config->search_space_duration; @@ -3986,28 +3877,11 @@ uint8_t fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t // max values are set according to TS38.213 Section 10.1 Table 10.1-1 ss0->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; ss0->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - switch(L){ - case 4: - ss0->nrofCandidates->aggregationLevel4 = (((max_agg>>2) > 4)? 4 : max_agg>>2); - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - break; - case 8: - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n0; - ss0->nrofCandidates->aggregationLevel8 = (((max_agg>>3) > 2)? 2 : max_agg>>3); - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - break; - case 16: - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n0; - ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss0->nrofCandidates->aggregationLevel16 = (((max_agg>>4) > 1)? 1 : max_agg>>4); - break; - default: - AssertFatal(1==0,"Invalid aggregation level %d for SS0\n",L); - } + ss0->nrofCandidates->aggregationLevel4 = (((max_agg>>2) > 4)? 4 : max_agg>>2); + ss0->nrofCandidates->aggregationLevel8 = (((max_agg>>3) > 2)? 2 : max_agg>>3); + ss0->nrofCandidates->aggregationLevel16 = (((max_agg>>4) > 1)? 1 : max_agg>>4); ss0->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; - return 1; } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 0a185157ef..ced29f066f 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -37,12 +37,6 @@ #include "nr_mac.h" #include "openair1/PHY/impl_defs_nr.h" -uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); - -lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index); - -int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index); - uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); @@ -53,7 +47,8 @@ int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slo int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, lte_frame_type_t frame_type); -uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialULBWP, +uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP, + const NR_BWP_UplinkCommon_t *initialULBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, @@ -63,7 +58,8 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialULBWP, void find_aggregation_candidates(uint8_t *aggregation_level, uint8_t *nr_of_candidates, - NR_SearchSpace_t *ss); + NR_SearchSpace_t *ss, + int maxL); void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss, uint16_t *slot_period, @@ -95,8 +91,6 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, uint16_t *N_RA_sfn, uint8_t *max_association_period); -uint8_t get_nr_prach_duration(uint8_t prach_format); - uint8_t get_pusch_mcs_table(long *mcs_Table, int is_tp, int dci_format, @@ -119,7 +113,6 @@ int64_t *get_prach_config_info(frequency_range_t freq_range, uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config); -int get_num_dmrs(uint16_t dmrs_mask ); uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position); int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbolt, uint8_t dmrs_typeA_position); @@ -134,6 +127,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD uint16_t ssb_start_symbol, NR_SubcarrierSpacing_t scs_ssb, frequency_range_t frequency_range, + int nr_band, uint32_t ssb_index, uint32_t ssb_period, uint32_t ssb_offset_point_a); @@ -148,7 +142,7 @@ void get_info_from_tda_tables(int default_abc, int *nrOfSymbols); void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); -uint8_t fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, int L); +void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); uint16_t compute_pucch_prb_size(uint8_t format, uint8_t nr_prbs, @@ -192,7 +186,7 @@ uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Posi @returns transformPrecoding value */ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_PUSCH_Config_t *pusch_config, - const NR_BWP_Uplink_t *ubwp, + const NR_BWP_UplinkDedicated_t *ubwp, uint8_t *dci_format, int rnti_type, uint8_t configuredGrant); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h index 5b4ebe2397..5def748d42 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h @@ -76,6 +76,9 @@ extern boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; extern eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif*/ +extern const uint32_t NR_SHORT_BSR_TABLE[NR_SHORT_BSR_TABLE_SIZE]; +extern const uint32_t NR_LONG_BSR_TABLE[NR_LONG_BSR_TABLE_SIZE]; + // Type0-PDCCH search space extern const int32_t table_38213_13_1_c1[16]; extern const int32_t table_38213_13_1_c2[16]; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c old mode 100755 new mode 100644 index 6f9e36d047..cef13b87fb --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -516,12 +516,12 @@ void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format else if (scd->defaultDownlinkBWP_Id) mac->DL_BWP_Id = *scd->defaultDownlinkBWP_Id; else - mac->DL_BWP_Id = 1; + mac->DL_BWP_Id = 0; if (scd->uplinkConfig && scd->uplinkConfig->firstActiveUplinkBWP_Id) mac->UL_BWP_Id = *scd->uplinkConfig->firstActiveUplinkBWP_Id; else - mac->UL_BWP_Id = 1; + mac->UL_BWP_Id = 0; } @@ -537,20 +537,22 @@ void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format void config_control_ue(NR_UE_MAC_INST_t *mac){ uint8_t coreset_id = 1, ss_id; - - NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - AssertFatal(scd->downlinkBWP_ToAddModList != NULL, "downlinkBWP_ToAddModList is null\n"); - AssertFatal(scd->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList->list->count is %d\n", scd->downlinkBWP_ToAddModList->list.count); - - config_bwp_ue(mac, NULL, NULL); NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - AssertFatal(dl_bwp_id != 0, "DL_BWP_Id is 0!"); + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; + if (dl_bwp_id==0) AssertFatal(mac->scc_SIB,"dl_bwp_id 0 (DL %d,UL %d) means mac->scc_SIB should exist here!\n",(int)mac->DL_BWP_Id,(int)mac->UL_BWP_Id); + NR_BWP_DownlinkCommon_t *bwp_Common = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Common : + &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; - NR_BWP_DownlinkCommon_t *bwp_Common = scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Common; - AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); - NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated = scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Dedicated; + if (dl_bwp_id > 0 ) { + AssertFatal(scd->downlinkBWP_ToAddModList != NULL, "downlinkBWP_ToAddModList is null\n"); + AssertFatal(scd->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList->list->count is %d\n", scd->downlinkBWP_ToAddModList->list.count); + } + NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Dedicated: + scd->initialDownlinkBWP; AssertFatal(dl_bwp_Dedicated != NULL, "dl_bwp_Dedicated is null\n"); + config_bwp_ue(mac, NULL, NULL); NR_SetupRelease_PDCCH_Config_t *pdcch_Config = dl_bwp_Dedicated->pdcch_Config; AssertFatal(pdcch_Config != NULL, "pdcch_Config is null\n"); @@ -574,16 +576,17 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){ AssertFatal(searchSpacesToAddModList->list.count < FAPI_NR_MAX_SS_PER_CORESET, "too many searchpaces per coreset %d\n", searchSpacesToAddModList->list.count); struct NR_UplinkConfig__uplinkBWP_ToAddModList *uplinkBWP_ToAddModList = scd->uplinkConfig->uplinkBWP_ToAddModList; - AssertFatal(uplinkBWP_ToAddModList != NULL, "uplinkBWP_ToAddModList is null\n"); - AssertFatal(uplinkBWP_ToAddModList->list.count == 1, "uplinkBWP_ToAddModList->list->count is %d\n", uplinkBWP_ToAddModList->list.count); - + if (ul_bwp_id > 0) { + AssertFatal(uplinkBWP_ToAddModList != NULL, "uplinkBWP_ToAddModList is null\n"); + AssertFatal(uplinkBWP_ToAddModList->list.count == 1, "uplinkBWP_ToAddModList->list->count is %d\n", uplinkBWP_ToAddModList->list.count); + } // check pdcch_Config, pdcch_ConfigCommon and DL BWP - mac->DLbwp[0] = scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]; - mac->coreset[dl_bwp_id - 1][coreset_id - 1] = controlResourceSetToAddModList->list.array[0]; + mac->DLbwp[0] = dl_bwp_id>0?scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]:NULL; + mac->coreset[dl_bwp_id][coreset_id - 1] = controlResourceSetToAddModList->list.array[0]; // Check dedicated UL BWP and pass to MAC - mac->ULbwp[0] = uplinkBWP_ToAddModList->list.array[0]; - AssertFatal(mac->ULbwp[0]->bwp_Dedicated != NULL, "UL bwp_Dedicated is null\n"); + mac->ULbwp[0] = ul_bwp_id>0?uplinkBWP_ToAddModList->list.array[0]:NULL; + if (mac->ULbwp[0]) AssertFatal(mac->ULbwp[0]->bwp_Dedicated != NULL, "UL bwp_Dedicated is null\n"); // check available Search Spaces in the searchSpacesToAddModList and pass to MAC // note: the network configures at most 10 Search Spaces per BWP per cell (including UE-specific and common Search Spaces). @@ -591,10 +594,10 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){ NR_SearchSpace_t *ss = searchSpacesToAddModList->list.array[ss_id]; AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); - AssertFatal(*ss->controlResourceSetId == mac->coreset[dl_bwp_id - 1][coreset_id - 1]->controlResourceSetId, "ss->controlResourceSetId is unknown\n"); + AssertFatal(*ss->controlResourceSetId == mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId, "ss->controlResourceSetId is unknown\n"); AssertFatal(ss->monitoringSymbolsWithinSlot != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot is null\n"); AssertFatal(ss->monitoringSymbolsWithinSlot->buf != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot->buf is null\n"); - mac->SSpace[0][0][ss_id] = ss; + mac->SSpace[dl_bwp_id][0][ss_id] = ss; } // Check available CSSs in the commonSearchSpaceList (list of additional common search spaces) @@ -602,15 +605,28 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){ for (int css_id = 0; css_id < commonSearchSpaceList->list.count; css_id++) { NR_SearchSpace_t *css = commonSearchSpaceList->list.array[css_id]; AssertFatal(css->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); - AssertFatal(*css->controlResourceSetId == mac->coreset[dl_bwp_id - 1][coreset_id - 1]->controlResourceSetId, "ss->controlResourceSetId is unknown\n"); + AssertFatal(*css->controlResourceSetId == 0 || *css->controlResourceSetId == mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId, "css->controlResourceSetId %ld is unknown, mac->coreset[%ld][%d]->controlResourceSetId %ld\n",*css->controlResourceSetId,dl_bwp_id,coreset_id-1,mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId); + AssertFatal(css->searchSpaceType != NULL, "css->searchSpaceType is null\n"); AssertFatal(css->monitoringSymbolsWithinSlot != NULL, "css->monitoringSymbolsWithinSlot is null\n"); AssertFatal(css->monitoringSymbolsWithinSlot->buf != NULL, "css->monitoringSymbolsWithinSlot->buf is null\n"); - mac->SSpace[0][0][ss_id] = css; + mac->SSpace[dl_bwp_id][0][ss_id] = css; ss_id++; } } +// todo handle mac_LogicalChannelConfig +int nr_rrc_mac_config_req_ue_logicalChannelBearer( + module_id_t module_id, + int cc_idP, + uint8_t gNB_index, + long logicalChannelIdentity, + boolean_t status){ + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + mac->logicalChannelBearer_exist[logicalChannelIdentity] = status; + return 0; +} + int nr_rrc_mac_config_req_ue( module_id_t module_id, int cc_idP, @@ -652,6 +668,9 @@ int nr_rrc_mac_config_req_ue( if(scell_group_config != NULL ){ mac->cg = scell_group_config; mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; + mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0; + mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0; + config_control_ue(mac); if (scell_group_config->spCellConfig->reconfigurationWithSync) { if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { @@ -671,8 +690,19 @@ int nr_rrc_mac_config_req_ue( LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); mac->cg = cell_group_config; mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; - // config_control_ue(mac); - // config_common_ue(mac,module_id,cc_idP); + + mac->scheduling_info.periodicBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->scheduling_info.retxBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; + LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + module_id, + mac->scheduling_info.periodicBSR_SF, + mac->scheduling_info.retxBSR_SF); + + config_control_ue(mac); + //config_common_ue(mac,module_id,cc_idP); /* if(mac_cell_group_configP != NULL){ if(mac_cell_group_configP->drx_Config != NULL ){ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h old mode 100755 new mode 100644 index 8a59b3599e..d076f2c59e --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -182,9 +182,9 @@ typedef struct { uint16_t All_lcid_buffer_size_lastTTI; /// buffer status for each lcid uint8_t LCID_status[NR_MAX_NUM_LCID]; - /// SR pending as defined in 36.321 + /// SR pending as defined in 38.321 uint8_t SR_pending; - /// SR_COUNTER as defined in 36.321 + /// SR_COUNTER as defined in 38.321 uint16_t SR_COUNTER; /// logical channel group ide for each LCID uint8_t LCGID[NR_MAX_NUM_LCID]; @@ -309,6 +309,7 @@ typedef struct { bool ack_received; uint8_t pucch_resource_indicator; uint16_t feedback_to_ul; + int is_common; frame_t dl_frame; int dl_slot; uint8_t ack; @@ -327,15 +328,6 @@ typedef struct { } RAR_grant_t; -typedef struct { - - uint8_t phr_reporting; - uint16_t truncated_bsr; - uint16_t short_bsr; - uint16_t long_bsr; - -} NR_UE_MAC_CE_t; - typedef struct { int n_HARQ_ACK; uint32_t ack_payload; @@ -344,6 +336,7 @@ typedef struct { uint32_t csi_part2_payload; int resource_indicator; int resource_set_id; + int is_common; int initial_pucch_id; NR_PUCCH_Resource_t *pucch_resource; int n_CCE; @@ -351,6 +344,7 @@ typedef struct { int8_t delta_pucch; } PUCCH_sched_t; + /*!\brief Top level UE MAC structure */ typedef struct { @@ -417,8 +411,15 @@ typedef struct { nr_ue_if_module_t *if_module; nr_phy_config_t phy_config; + /// BSR report flag management + uint8_t BSR_reporting_active; + + /// LogicalChannelConfig has bearer. + boolean_t logicalChannelBearer_exist[NR_MAX_NUM_LCID]; NR_UE_SCHEDULING_INFO scheduling_info; - NR_UE_MAC_CE_t nr_ue_mac_ce; + + /// PHR + uint8_t PHR_reporting_active; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config; NR_SearchSpace_t *search_space_zero; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h old mode 100755 new mode 100644 index 83ff1d3a9e..a9632fb330 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -40,6 +40,10 @@ #define NR_DL_MAX_DAI (4) /* TS 38.213 table 9.1.3-1 Value of counter DAI for DCI format 1_0 and 1_1 */ #define NR_DL_MAX_NB_CW (2) /* number of downlink code word */ +/**\brief initialize the field in nr_mac instance + \param module_id module id */ +void nr_ue_init_mac(module_id_t module_idP); + /**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message \param module_id module id \param cc_id component carrier id @@ -74,6 +78,20 @@ int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id, uint8_t *pduP, uint32_t pdu_len); +/**\brief primitive from RRC layer to MAC layer to set if bearer exists for a logical channel. todo handle mac_LogicalChannelConfig + \param module_id module id + \param cc_id component carrier id + \param gNB_index gNB index + \param long logicalChannelIdentity + \param boolean_t status*/ +int nr_rrc_mac_config_req_ue_logicalChannelBearer( + module_id_t module_id, + int cc_idP, + uint8_t gNB_index, + long logicalChannelIdentity, + boolean_t status +); + /**\brief primitive from RRC layer to MAC layer for configuration L1/L2, now supported 4 rrc messages: MIB, cell_group_config for MAC/PHY, spcell_config(serving cell config) \param module_id module id \param cc_id component carrier id @@ -125,7 +143,53 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, int slot, int thread_id); -int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, int slotP); +/*! \fn int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP); + \brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3 SDUs and generates header and forms the complete MAC SDU. +\param[in] Mod_id Instance id of UE in machine +\param[in] frameP subframe number +\param[in] slotP slot number +*/ +int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP); + +/*! \fn boolean_t update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index) + \brief get the rlc stats and update the bsr level for each lcid +\param[in] Mod_id instance of the UE +\param[in] frameP Frame index +\param[in] slot slotP number +\param[in] uint8_t gNB_index +*/ +boolean_t nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index); + +/*! \fn nr_locate_BsrIndexByBufferSize (int *table, int size, int value) + \brief locate the BSR level in the table as defined in 38.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. +\param[in] *table Pointer to BSR table +\param[in] size Size of the table +\param[in] value Value of the buffer +\return the index in the BSR_LEVEL table +*/ +uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size, + int value); + +/*! \fn int nr_get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) + \brief get the number of subframe from the periodic BSR timer configured by the higher layers +\param[in] periodicBSR_Timer timer for periodic BSR +\return the number of subframe +*/ +int nr_get_sf_periodicBSRTimer(uint8_t bucketSize); + +/*! \fn int nr_get_ms_bucketsizeduration(uint8_t bucketSize) + \brief get the time in ms form the bucket size duration configured by the higher layer +\param[in] bucketSize the bucket size duration +\return the time in ms +*/ +int nr_get_ms_bucketsizeduration(uint8_t bucketsizeduration); + +/*! \fn int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer) + \brief get the number of subframe form the bucket size duration configured by the higher layer +\param[in] retxBSR_Timer timer for regular BSR +\return the time in sf +*/ +int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer); int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, fapi_nr_dci_indication_pdu_t *dci_ind); int nr_ue_process_dci_indication_pdu(module_id_t module_id, int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci); @@ -170,7 +234,13 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, int pdu_id); int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, - NR_UE_MAC_INST_t *mac); + NR_UE_MAC_INST_t *mac, + uint8_t power_headroom, // todo: NR_POWER_HEADROOM_CMD *power_headroom, + uint16_t *crnti, + NR_BSR_SHORT *truncated_bsr, + NR_BSR_SHORT *short_bsr, + NR_BSR_LONG *long_bsr + ); void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); @@ -178,6 +248,14 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); +void get_bwp_info(NR_UE_MAC_INST_t *mac, + int dl_bwp_id, + int ul_bwp_id, + NR_BWP_DownlinkDedicated_t **bwpd, + NR_BWP_DownlinkCommon_t **bwpc, + NR_BWP_UplinkDedicated_t **ubwpd, + NR_BWP_UplinkCommon_t **ubwpc); + uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint8_t dci_format, uint8_t dci_length, @@ -185,15 +263,20 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint64_t *dci_pdu, dci_pdu_rel15_t *nr_pdci_info_extracted); +NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); +NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon); + int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList, + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, uint8_t time_domain_ind, int default_abc, bool use_default); - uint8_t nr_ue_get_sdu(module_id_t module_idP, + int cc_id, frame_t frameP, sub_frame_t subframe, uint8_t gNB_index, @@ -212,6 +295,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, uint8_t dai, int n_CCE, int N_CCE, + int is_common, frame_t frame, int slot); @@ -256,23 +340,6 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_pucch_pdu *pucch_pdu, int O_SR, int O_ACK, int O_CSI); -/** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. - @param Mod_id Module id of UE - @returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE -*/ -int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t module_idP, uint8_t CC_id); - -/** \brief Function to compute DELTA_PREAMBLE from 38.321 subclause 7.3 - (for RA power ramping procedure and Msg3 PUSCH power control policy) - @param Mod_id Module id of UE - @returns DELTA_PREAMBLE -*/ -int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format); - -/** \brief Function to compute configured maximum output power according to clause 6.2.4 of 3GPP TS 38.101-1 version 16.5.0 Release 16 - @param Mod_id Module id of UE -*/ -long nr_get_Pcmax(module_id_t mod_id); /* Random Access */ @@ -333,7 +400,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot); If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for -andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321) +andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 38.321) @param mod_id Index of UE instance @param CC_id Component Carrier Index @param frame @@ -376,10 +443,6 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); -void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, - uint8_t *nb_dmrs_re_per_rb, - uint16_t *number_dmrs_symbols); - void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index b27837043f..af0c84dc4b 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -52,8 +52,9 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST); - for (int j=0;jscell_group_config) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c index 7f1011fb28..eaaa5f5f72 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c @@ -35,150 +35,9 @@ #include "mac_defs.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" #include "NR_P-Max.h" -/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ -int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){ - - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc!=NULL) ? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; - NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; - int prach_sequence_length = (mac->scc!=NULL)?(mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1) : (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1); - uint8_t prachConfigIndex, mu; - - AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); - - // SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211 - - switch (scs){ - case NR_SubcarrierSpacing_kHz15: - mu = 0; - break; - - case NR_SubcarrierSpacing_kHz30: - mu = 1; - break; - - case NR_SubcarrierSpacing_kHz60: - mu = 2; - break; - - case NR_SubcarrierSpacing_kHz120: - mu = 3; - break; - - case NR_SubcarrierSpacing_kHz240: - mu = 4; - break; - - case NR_SubcarrierSpacing_spare3: - mu = 5; - break; - - case NR_SubcarrierSpacing_spare2: - mu = 6; - break; - - case NR_SubcarrierSpacing_spare1: - mu = 7; - break; - - default: - AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs); - } - - // Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211 - - prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - - if (prach_sequence_length == 0) { - AssertFatal(prach_format < 4, "Illegal PRACH format %d for sequence length 839\n", prach_format); - switch (prach_format) { - - // long preamble formats - case 0: - case 3: - return 0; - - case 1: - return -3; - - case 2: - return -6; - } - } else { - switch (prach_format) { // short preamble formats - case 0: - case 3: - return 8 + 3*mu; - - case 1: - case 4: - case 8: - return 5 + 3*mu; - - case 2: - case 5: - return 3 + 3*mu; - - case 6: - return 3*mu; - - case 7: - return 5 + 3*mu; - - default: - AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex); - } - } - return 0; -} - -// TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration -// Measurement units: -// - preambleReceivedTargetPower dBm (-202..-60, 2 dBm granularity) -// - delta_preamble dB -// - RA_PREAMBLE_POWER_RAMPING_STEP dB -// - POWER_OFFSET_2STEP_RA dB -// returns receivedTargerPower in dBm -int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){ - - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - int8_t receivedTargerPower; - int8_t delta_preamble; - - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc != NULL) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; - long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower; - delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format); - - receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP + prach_resources->POWER_OFFSET_2STEP_RA; - - LOG_D(MAC, "In %s: receivedTargerPower is %d dBm \n", __FUNCTION__, receivedTargerPower); - - return receivedTargerPower; -} - -void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, - uint8_t *nb_dmrs_re_per_rb, - uint16_t *number_dmrs_symbols){ - - int start_symbol = pusch_pdu->start_symbol_index; - uint8_t number_of_symbols = pusch_pdu->nr_of_symbols; - uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos; - uint8_t dmrs_type = pusch_pdu->dmrs_config_type; - uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data; - - *number_dmrs_symbols = 0; - for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { - if((ul_dmrs_symb_pos >> i) & 0x01) - *number_dmrs_symbols += 1; - } - - *nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data; - -} // Implementation of 6.2.4 Configured ransmitted power // 3GPP TS 38.101-1 version 16.5.0 Release 16 diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h old mode 100644 new mode 100755 similarity index 65% rename from openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h rename to openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h index f0f9d3e28f..8b3f00af43 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h +++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h @@ -1,4 +1,4 @@ - /* +/* * 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. @@ -19,20 +19,8 @@ * contact@openairinterface.org */ -#ifndef _NR_PDCP_ENTITY_SRB_H_ -#define _NR_PDCP_ENTITY_SRB_H_ - -#include "nr_pdcp_entity.h" - -typedef struct { - nr_pdcp_entity_t common; - int srb_id; -} nr_pdcp_entity_srb_t; - -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); - - -#endif /* _NR_PDCP_ENTITY_SRB_H_ */ +/** \brief Function to compute configured maximum output power according to clause 6.2.4 of 3GPP TS 38.101-1 version 16.5.0 Release 16 + @param Mod_id Module id of UE +*/ +long nr_get_Pcmax(module_id_t mod_id); +/** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 83784634fc..2d059783fe 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -30,23 +30,18 @@ * \warning */ -/* Tools */ -#include "SIMULATION/TOOLS/sim.h" // for taus - /* RRC */ #include "NR_RACH-ConfigCommon.h" #include "RRC/NR_UE/rrc_proto.h" /* PHY */ -#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" -#include "PHY/defs_common.h" -#include "PHY/defs_nr_common.h" #include "PHY/NR_UE_ESTIMATION/nr_estimation.h" /* MAC */ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" #include @@ -198,6 +193,130 @@ void init_RA(module_id_t mod_id, } } + +/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ +int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){ + + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc!=NULL) ? + mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; + int prach_sequence_length = (mac->scc!=NULL)?(mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1) : (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1); + uint8_t prachConfigIndex, mu; + + AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); + + // SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211 + + switch (scs){ + case NR_SubcarrierSpacing_kHz15: + mu = 0; + break; + + case NR_SubcarrierSpacing_kHz30: + mu = 1; + break; + + case NR_SubcarrierSpacing_kHz60: + mu = 2; + break; + + case NR_SubcarrierSpacing_kHz120: + mu = 3; + break; + + case NR_SubcarrierSpacing_kHz240: + mu = 4; + break; + + case NR_SubcarrierSpacing_spare3: + mu = 5; + break; + + case NR_SubcarrierSpacing_spare2: + mu = 6; + break; + + case NR_SubcarrierSpacing_spare1: + mu = 7; + break; + + default: + AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs); + } + + // Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211 + + prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; + + if (prach_sequence_length == 0) { + AssertFatal(prach_format < 4, "Illegal PRACH format %d for sequence length 839\n", prach_format); + switch (prach_format) { + + // long preamble formats + case 0: + case 3: + return 0; + + case 1: + return -3; + + case 2: + return -6; + } + } else { + switch (prach_format) { // short preamble formats + case 0: + case 3: + return 8 + 3*mu; + + case 1: + case 4: + case 8: + return 5 + 3*mu; + + case 2: + case 5: + return 3 + 3*mu; + + case 6: + return 3*mu; + + case 7: + return 5 + 3*mu; + + default: + AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex); + } + } + return 0; +} + +// TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration +// Measurement units: +// - preambleReceivedTargetPower dBm (-202..-60, 2 dBm granularity) +// - delta_preamble dB +// - RA_PREAMBLE_POWER_RAMPING_STEP dB +// - POWER_OFFSET_2STEP_RA dB +// returns receivedTargerPower in dBm +int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){ + + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + int8_t receivedTargerPower; + int8_t delta_preamble; + + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc != NULL) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower; + delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format); + + receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP + prach_resources->POWER_OFFSET_2STEP_RA; + + LOG_D(MAC, "In %s: receivedTargerPower is %d dBm \n", __FUNCTION__, receivedTargerPower); + + return receivedTargerPower; +} + void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, fapi_nr_ul_config_prach_pdu *prach_pdu){ // Determine the SSB to RACH mapping ratio @@ -280,6 +399,10 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t int PLThreshold = 0; long deltaPreamble_Msg3 = 0; uint8_t noGroupB = 0; + // Random seed generation + long long tmp = rdtsc_oai(); + unsigned short int *seed = (unsigned short int*)&tmp; + RA_config_t *ra = &mac->ra; NR_RACH_ConfigCommon_t *setup; if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; @@ -378,28 +501,28 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t if(ra->ra_PreambleIndex < 0 || ra->ra_PreambleIndex > 63) { if (noGroupB) { // use Group A preamble - ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb); + ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % ra->cb_preambles_per_ssb); ra->RA_usedGroupA = 1; } else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) { // Group B is configured and RA preamble Group A is used // - todo add condition on CCCH_sdu_size for initiation by CCCH - ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA); + ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % sizeOfRA_PreamblesGroupA); ra->RA_usedGroupA = 1; } else { // Group B preamble is configured and used // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A // the remaining belong to RA Preambles Group B - ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); + ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + (nrand48(seed) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); ra->RA_usedGroupA = 0; } } } else { // Msg3 is being retransmitted if (ra->RA_usedGroupA && noGroupB) { - ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb); + ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % ra->cb_preambles_per_ssb); } else if (ra->RA_usedGroupA && !noGroupB){ - ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA); + ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % sizeOfRA_PreamblesGroupA); } else { - ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); + ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + (nrand48(seed) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); } } prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex; @@ -467,7 +590,8 @@ void nr_get_prach_resources(module_id_t mod_id, if (rach_ConfigDedicated) { if (rach_ConfigDedicated->cfra){ uint8_t cfra_ssb_resource_idx = 0; - prach_resources->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex; + ra->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex; + prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex; LOG_D(MAC, "In %s: selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n", __FUNCTION__, prach_resources->ra_PreambleIndex, cfra_ssb_resource_idx); } } else { @@ -616,7 +740,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } else { - size_sdu = nr_write_ce_ulsch_pdu(pdu, mac); + size_sdu = nr_write_ce_ulsch_pdu(pdu, mac, 0, &(mac->crnti), NULL, NULL, NULL); pdu += size_sdu; ra->Msg3_size = size_sdu; @@ -837,6 +961,9 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; + // Random seed generation + long long tmp = rdtsc_oai(); + unsigned short int *seed = (unsigned short int*)&tmp; ra->first_Msg3 = 1; ra->ra_PreambleIndex = -1; @@ -850,7 +977,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res LOG_D(MAC, "In %s: [UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n", __FUNCTION__, mod_id, frame, slot, ra->preambleTransMax); - ra->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1); + ra->RA_backoff_cnt = nrand48(seed) % (prach_resources->RA_PREAMBLE_BACKOFF + 1); prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1; prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += 2; // 2 dB increment prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(prach_resources, mod_id, CC_id); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 7f62ee9b3e..2abcb60e91 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -51,16 +51,25 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { - LOG_D(MAC,"Filling search candidates for DCI\n"); + LOG_D(NR_MAC,"Filling search candidates for DCI\n"); uint8_t aggregation; - find_aggregation_candidates(&aggregation, - &rel15->number_of_candidates, - ss); + uint8_t number_of_candidates=0; + rel15->number_of_candidates=0; + int i=0; + for (int maxL=16;maxL>0;maxL>>=1) { + find_aggregation_candidates(&aggregation, + &number_of_candidates, + ss,maxL); - for (int i=0; inumber_of_candidates; i++) { - rel15->CCE[i] = i*aggregation; - rel15->L[i] = aggregation; + if (number_of_candidates>0) { + LOG_D(NR_MAC,"L %d, number of candidates %d, aggregation %d\n",maxL,number_of_candidates,aggregation); + rel15->number_of_candidates += number_of_candidates; + for (int j=0; jCCE[i] = j*aggregation; + rel15->L[i] = aggregation; + } + } } } @@ -82,18 +91,14 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t if (scc!=NULL || scc_SIB != NULL) { initialDownlinkBWP = scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP; initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP; - - bwp_Common = bwp_id>0 ? mac->DLbwp[bwp_id-1]->bwp_Common : NULL; } + bwp_Common = bwp_id>0 ? mac->DLbwp[bwp_id-1]->bwp_Common : NULL; NR_SearchSpace_t *ss; NR_ControlResourceSet_t *coreset; if(ss_id>=0) { - AssertFatal(mac->scc != NULL, "scc is null\n"); - initialDownlinkBWP = scc->downlinkConfigCommon->initialDownlinkBWP; - bwp_Common = mac->DLbwp[bwp_id - 1]->bwp_Common; - ss = mac->SSpace[bwp_id - 1][coreset_id - 1][ss_id]; - coreset = mac->coreset[bwp_id - 1][coreset_id - 1]; + ss = mac->SSpace[bwp_id][coreset_id - 1][ss_id]; + coreset = mac->coreset[bwp_id][coreset_id - 1]; rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; } else { ss = mac->search_space_zero; @@ -153,7 +158,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; } for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); } break; case NR_RNTI_RA: @@ -161,14 +166,15 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.ra_rnti; - rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); if (get_softmodem_params()->sa) { - rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; } else { // NSA mode is not using the Initial BWP + rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - rel15->dci_length_options[0] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); + rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); break; case NR_RNTI_P: break; @@ -179,11 +185,12 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.t_crnti; - rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - for (int i = 0; i < rel15->num_dci_options; i++) - rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, bwp_id); + for (int i = 0; i < rel15->num_dci_options; i++) { + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, bwp_id); + } break; case NR_RNTI_SP_CSI: break; @@ -205,7 +212,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0); + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0); } break; case NR_RNTI_SFI: @@ -248,20 +255,19 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl RA_config_t *ra = &mac->ra; int ss_id; - uint8_t bwp_id = (mac->cg) ? 1 : 0, coreset_id = (mac->cg) ? 1 : 0; + uint8_t bwp_id = (mac->cg) ? mac->DL_BWP_Id : 0, coreset_id = (mac->cg) ? 1 : 0; //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; - NR_BWP_Downlink_t *bwp = (mac->cg) ? mac->DLbwp[bwp_id - 1] : NULL; + NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; - LOG_D(MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); + LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); - if (mac->cg) { // do this only after we have a Master or Secondary Cell group - // loop over all available SS for BWP ID 1, CORESET ID 1 - if (bwp) { - for (ss_id = 0; ss_id < FAPI_NR_MAX_SS_PER_CORESET && mac->SSpace[bwp_id - 1][coreset_id - 1][ss_id] != NULL; ss_id++){ - LOG_D(MAC, "[DCI_CONFIG] ss_id %d\n",ss_id); - NR_SearchSpace_t *ss = mac->SSpace[bwp_id - 1][coreset_id - 1][ss_id]; + // loop over all available SS for CORESET ID 1 + if (bwpd) { + for (ss_id = 0; ss_id < FAPI_NR_MAX_SS_PER_CORESET && mac->SSpace[bwp_id][coreset_id - 1][ss_id] != NULL; ss_id++){ + LOG_D(NR_MAC, "[DCI_CONFIG] ss_id %d\n",ss_id); + NR_SearchSpace_t *ss = mac->SSpace[bwp_id][coreset_id - 1][ss_id]; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - NR_BWP_DownlinkCommon_t *bwp_Common = bwp->bwp_Common; NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; struct NR_PhysicalCellGroupConfig *phy_cgc = mac->cg->physicalCellGroupConfig; switch (ss->searchSpaceType->present){ @@ -275,7 +281,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=calloc(1,sizeof(*pdcch_ConfigCommon->choice.setup->searchSpaceSIB1)); } *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 = 0; - LOG_D(MAC, "[DCI_CONFIG] Configure SearchSpace#0 of the initial BWP\n"); + LOG_D(NR_MAC, "[DCI_CONFIG] Configure SearchSpace#0 of the initial BWP\n"); } if (ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0){ // check available SS IDs @@ -308,30 +314,30 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl if (pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ // Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG - LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); + //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); } } if (pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){ if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){ // Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG - LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); + //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); } } if (pdcch_ConfigCommon->choice.setup->pagingSearchSpace){ if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->pagingSearchSpace){ // Configure monitoring of PDCCH candidates in Type2-PDCCH common search space on the MCG - LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); + //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); } } if (phy_cgc){ if (phy_cgc->cs_RNTI){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n"); } if (phy_cgc->ext1){ if (phy_cgc->ext1->mcs_C_RNTI){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n"); } } } @@ -339,71 +345,68 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl // DCI 2_0 if (ss->searchSpaceType->choice.common->dci_Format2_0){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_0 with CRC scrambled by SFI-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); } // DCI 2_1 if (ss->searchSpaceType->choice.common->dci_Format2_1){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_1 with CRC scrambled by INT-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); } // DCI 2_2 if (ss->searchSpaceType->choice.common->dci_Format2_2){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_2 with CRC scrambled by TPC-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); } // DCI 2_3 if (ss->searchSpaceType->choice.common->dci_Format2_3){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_3 with CRC scrambled by TPC-SRS-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet..."); + LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); } break; case NR_SearchSpace__searchSpaceType_PR_ue_Specific: // this is an USS - if (ss->searchSpaceType->choice.ue_Specific){ - if(ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1){ + if (ss->searchSpaceType->choice.ue_Specific && + ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 && + (ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && + mac->crnti > 0) { // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI - if ((ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && mac->crnti > 0) { - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - rel15->num_dci_options = 2; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; - rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); - fill_dci_search_candidates(ss, rel15); + LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); + rel15->num_dci_options = 2; + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); + fill_dci_search_candidates(ss, rel15); -#ifdef DEBUG_DCI - LOG_D(MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", +//#ifdef DEBUG_DCI + LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", ss_id, ss->searchSpaceType->choice.ue_Specific, - ss->searchSpaceType->present, - ss->searchSpaceType->choice.ue_Specific->dci_Formats); -#endif - } - if (phy_cgc){ - if (phy_cgc->cs_RNTI){ + (int)ss->searchSpaceType->present, + (int)ss->searchSpaceType->choice.ue_Specific->dci_Formats); +//#endif + } + if (phy_cgc){ + if (phy_cgc->cs_RNTI){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n"); LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - if (phy_cgc->sp_CSI_RNTI){ + } + if (phy_cgc->sp_CSI_RNTI){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by SP-CSI-RNTI...\n"); LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - if (phy_cgc->ext1){ - if (phy_cgc->ext1->mcs_C_RNTI){ + } + if (phy_cgc->ext1 && + phy_cgc->ext1->mcs_C_RNTI){ LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n"); LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - } - } - } + } } break; default: AssertFatal(1 == 0, "[DCI_CONFIG] Unrecognized search space type..."); break; - } - } - } + } // switch searchspace + } // for ss_id } else { @@ -411,8 +414,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } // Search space 0, CORESET ID 0 - NR_BWP_DownlinkCommon_t *bwp_Common = bwp ? bwp->bwp_Common : NULL; - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp?bwp_Common->pdcch_ConfigCommon:NULL; + NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; if (pdcch_ConfigCommon && pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 6e22a05b17..d555014bc8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -54,7 +54,6 @@ /* PHY */ #include "PHY/NR_TRANSPORT/nr_dci.h" #include "executables/softmodem-common.h" -#include "SCHED_NR_UE/defs.h" /* utils */ #include "assertions.h" @@ -135,6 +134,131 @@ const initial_pucch_resource_t initial_pucch_resource[16] = { }; +void nr_ue_init_mac(module_id_t module_idP) { + int i; + + NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + // default values as deined in 38.331 sec 9.2.2 + LOG_I(NR_MAC, "[UE%d] Applying default macMainConfig\n", module_idP); + //mac->scheduling_info.macConfig=NULL; + mac->scheduling_info.retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf10240; + mac->scheduling_info.periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_infinity; +// mac->scheduling_info.periodicPHR_Timer = NR_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; +// mac->scheduling_info.prohibitPHR_Timer = NR_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; +// mac->scheduling_info.PathlossChange_db = NR_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; +// mac->PHR_state = NR_MAC_MainConfig__phr_Config_PR_setup; + mac->scheduling_info.SR_COUNTER = 0; + mac->scheduling_info.sr_ProhibitTimer = 0; + mac->scheduling_info.sr_ProhibitTimer_Running = 0; +// mac->scheduling_info.maxHARQ_Tx = NR_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; +// mac->scheduling_info.ttiBundling = 0; +// mac->scheduling_info.extendedBSR_Sizes_r10 = 0; +// mac->scheduling_info.extendedPHR_r10 = 0; +// mac->scheduling_info.drx_config = NULL; +// mac->scheduling_info.phr_config = NULL; + // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. + mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->BSR_reporting_active = BSR_TRIGGER_NONE; +// mac->scheduling_info.periodicPHR_SF = nr_get_sf_perioidicPHR_Timer(mac->scheduling_info.periodicPHR_Timer); +// mac->scheduling_info.prohibitPHR_SF = nr_get_sf_prohibitPHR_Timer(mac->scheduling_info.prohibitPHR_Timer); +// mac->scheduling_info.PathlossChange_db = nr_get_db_dl_PathlossChange(mac->scheduling_info.PathlossChange); +// mac->PHR_reporting_active = 0; + + for (i = 0; i < NR_MAX_NUM_LCID; i++) { + LOG_D(NR_MAC, "[UE%d] Applying default logical channel config for LCGID %d\n", + module_idP, i); + mac->scheduling_info.Bj[i] = -1; + mac->scheduling_info.bucket_size[i] = -1; + + if (i < UL_SCH_LCID_DTCH) { // initialize all control channels lcgid to 0 + mac->scheduling_info.LCGID[i] = 0; + } else { // initialize all the data channels lcgid to 1 + mac->scheduling_info.LCGID[i] = 1; + } + + mac->scheduling_info.LCID_status[i] = LCID_EMPTY; + mac->scheduling_info.LCID_buffer_remain[i] = 0; + for (int i=0;ifirst_ul_tx[i]=1; + } +} + +void get_bwp_info(NR_UE_MAC_INST_t *mac, + int dl_bwp_id, + int ul_bwp_id, + NR_BWP_DownlinkDedicated_t **bwpd, + NR_BWP_DownlinkCommon_t **bwpc, + NR_BWP_UplinkDedicated_t **ubwpd, + NR_BWP_UplinkCommon_t **ubwpc) { + + if (dl_bwp_id > 0) { + AssertFatal(mac->DLbwp[dl_bwp_id-1]!=NULL,"mac->DLbwp[%d] is null, shouldn't be\n", + (int)dl_bwp_id-1); + *bwpd = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated; + if (mac->DLbwp[dl_bwp_id-1]->bwp_Common) *bwpc = mac->DLbwp[dl_bwp_id-1]->bwp_Common; + else if (mac->scc_SIB) *bwpc = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + else if (mac->scc) *bwpc = mac->scc->downlinkConfigCommon->initialDownlinkBWP; + AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); + } else { + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP) + *bwpd = mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + if (mac->scc_SIB) *bwpc = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + else if (mac->scc) *bwpc = mac->scc->downlinkConfigCommon->initialDownlinkBWP; + AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); + } + + if (ul_bwp_id > 0) { + AssertFatal(mac->ULbwp[ul_bwp_id-1]!=NULL,"mac->ULbwp[%d] is null, shouldn't be\n", + ul_bwp_id-1); + *ubwpd = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated; + if (mac->ULbwp[ul_bwp_id-1]->bwp_Common) *ubwpc = mac->ULbwp[ul_bwp_id-1]->bwp_Common; + else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; + else if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; + AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); + + } + else { + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) + *ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; + else if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; + AssertFatal(*ubwpc!=NULL,"ubwpc shouldn't be null\n"); + } +} + +NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon) { + + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; + + if (pdsch_Config && + pdsch_Config->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; + else if (pdsch_ConfigCommon->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = pdsch_ConfigCommon->pdsch_TimeDomainAllocationList; + + return(pdsch_TimeDomainAllocationList); +} + +NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon) { + + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList=NULL; + + if (pusch_Config && + pusch_Config->pusch_TimeDomainAllocationList) + pusch_TimeDomainAllocationList = pusch_Config->pusch_TimeDomainAllocationList->choice.setup; + else if (pusch_ConfigCommon->pusch_TimeDomainAllocationList) + pusch_TimeDomainAllocationList = pusch_ConfigCommon->pusch_TimeDomainAllocationList; + + return(pusch_TimeDomainAllocationList); +} + int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ RA_config_t *ra = &mac->ra; @@ -171,7 +295,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id, uint16_t ssb_start_subcarrier, uint16_t cell_id) { - LOG_I(MAC,"[L2][MAC] decode mib\n"); + LOG_D(MAC,"[L2][MAC] decode mib\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); mac->physCellId = cell_id; @@ -342,6 +466,8 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p } int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList, + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, uint8_t time_domain_ind, @@ -398,17 +524,6 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) */ if(dlsch_config_pdu != NULL){ - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (mac->DLbwp[0] && - mac->DLbwp[0]->bwp_Dedicated && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) - pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - if (pdsch_TimeDomainAllocationList && use_default==false) { if (time_domain_ind >= pdsch_TimeDomainAllocationList->list.count) { @@ -446,23 +561,6 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, * TS 38.214 subclause 6.1.2.1 Resource allocation in time domain (uplink) */ if(pusch_config_pdu != NULL){ - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - else pusch_TimeDomainAllocationList = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - if (pusch_TimeDomainAllocationList && use_default==false) { if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", @@ -638,7 +736,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Config PUSCH PDU ret = nr_config_pusch_pdu(mac, pusch_config_pdu, dci, NULL, rnti, &dci_format); - } + } else AssertFatal(1==0,"Cannot schedule PUSCH\n"); break; } @@ -698,8 +796,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; NR_PDSCH_Config_t *pdsch_config= (mac->DLbwp[0]) ? mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - uint16_t BWPSize = n_RB_DLBWP; - + int is_common=0; if(rnti == SI_RNTI) { NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; default_abc = type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern; @@ -708,7 +805,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; if (pdsch_config) pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL; // For PDSCH with mapping type A, the UE shall assume dmrs-AdditionalPosition='pos2' - BWPSize = dlsch_config_pdu_1_0->BWPSize; } else { if (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti){ dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH; @@ -716,9 +812,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; } if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) { - if (mac->scc == NULL) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (mac->scc == NULL) { // use coreset0 + dlsch_config_pdu_1_0->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + dlsch_config_pdu_1_0->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; + is_common=1; } else { dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -727,7 +824,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (!get_softmodem_params()->sa) { // NSA mode is not using the Initial BWP dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pdsch_config = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup; - BWPSize = dlsch_config_pdu_1_0->BWPSize; } } else if (mac->DLbwp[0]) { dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -744,15 +840,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* IDENTIFIER_DCI_FORMATS */ /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ - if (nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,BWPSize,dci->frequency_domain_assignment.val) < 0) { + if (nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,dlsch_config_pdu_1_0->BWPSize,dci->frequency_domain_assignment.val) < 0) { LOG_W(MAC, "[%d.%d] Invalid frequency_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } - /* TIME_DOM_RESOURCE_ASSIGNMENT */ - if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_0,dci->time_domain_assignment.val,default_abc,rnti==SI_RNTI) < 0) { - LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); - return -1; - } + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; if (mac->DLbwp[0] && @@ -765,6 +857,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + /* TIME_DOM_RESOURCE_ASSIGNMENT */ + if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,pdsch_TimeDomainAllocationList,NULL,dlsch_config_pdu_1_0,dci->time_domain_assignment.val,default_abc,rnti==SI_RNTI) < 0) { + LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); + return -1; + } int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_0->start_symbol <= 3)? typeA: typeB); /* dmrs symbol positions*/ @@ -851,7 +948,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->accumulated_delta_PUCCH, 1+dci->pdsch_to_harq_feedback_timing_indicator.val, dci->dai[0].val, - dci_ind->n_CCE,dci_ind->N_CCE, + dci_ind->n_CCE,dci_ind->N_CCE,is_common, frame,slot); LOG_D(MAC,"(nr_ue_procedures.c) rnti = %x dl_config->number_pdus = %d\n", @@ -917,22 +1014,29 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 47 DMRS_SEQ_INI: */ - if (dci->bwp_indicator.val != 1) { - LOG_W(MAC, "[%d.%d] bwp_indicator != 1! Possibly due to false DCI. Ignoring DCI!\n", frame, slot); + if (dci->bwp_indicator.val > 1) { + LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > 1 Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); return -1; } config_bwp_ue(mac, &dci->bwp_indicator.val, &dci_format); NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_PDSCH_Config_t *pdsch_config=mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_PDSCH_Config_t *pdsch_Config=NULL; + NR_BWP_DownlinkDedicated_t *bwpd=NULL; + NR_BWP_DownlinkCommon_t *bwpc=NULL; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_BWP_UplinkCommon_t *ubwpc=NULL; + get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); + pdsch_Config = bwpd->pdsch_Config->choice.setup; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_1->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_1->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_1->BWPStart = NRRIV2PRBOFFSET(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_1->SubcarrierSpacing = bwpc->genericParameters.subcarrierSpacing; /* IDENTIFIER_DCI_FORMATS */ /* CARRIER_IND */ @@ -944,38 +1048,28 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr return -1; } /* TIME_DOM_RESOURCE_ASSIGNMENT */ - if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_1,dci->time_domain_assignment.val,0,false) < 0) { + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = choose_dl_tda_list(pdsch_Config,bwpc->pdsch_ConfigCommon->choice.setup); + if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,pdsch_TimeDomainAllocationList,NULL,dlsch_config_pdu_1_1,dci->time_domain_assignment.val,0,false) < 0) { LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (mac->DLbwp[0] && - mac->DLbwp[0]->bwp_Dedicated && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) - pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_1->start_symbol <= 3)? typeA: typeB); /* dmrs symbol positions*/ - dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, - mac->scc->dmrs_TypeA_Position, + dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, + mac->scc? mac->scc->dmrs_TypeA_Position:mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_1->number_symbols, dlsch_config_pdu_1_1->start_symbol, mappingtype); - dlsch_config_pdu_1_1->dmrsConfigType = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; + dlsch_config_pdu_1_1->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; /* TODO: fix number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214, using tables 7.3.1.2.2-1, 7.3.1.2.2-2, 7.3.1.2.2-3, 7.3.1.2.2-4 of 3GPP TS 38.212 */ dlsch_config_pdu_1_1->n_dmrs_cdm_groups = 1; /* VRB_TO_PRB_MAPPING */ - if ((pdsch_config->resourceAllocation == 1) && (pdsch_config->vrb_ToPRB_Interleaver != NULL)) + if ((pdsch_Config->resourceAllocation == 1) && (pdsch_Config->vrb_ToPRB_Interleaver != NULL)) dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping.val == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; /* PRB_BUNDLING_SIZE_IND */ dlsch_config_pdu_1_1->prb_bundling_size_ind = dci->prb_bundling_size_indicator.val; @@ -1016,9 +1110,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - pucch_res_set_cnt = mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.count; + pucch_res_set_cnt = ubwpd->pucch_Config->choice.setup->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { + if (dci->pucch_resource_indicator < ubwpd->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { valid = 1; break; } @@ -1032,13 +1126,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint8_t n_codewords = 1; // FIXME!!! long *max_length = NULL; long *dmrs_type = NULL; - if (pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA) { - max_length = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength; - dmrs_type = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type; + if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA) { + max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength; + dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type; } - if (pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB) { - max_length = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->maxLength; - dmrs_type = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type; + if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB) { + max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->maxLength; + dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type; } if ((dmrs_type == NULL) && (max_length == NULL)){ // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 @@ -1133,9 +1227,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 Table 9.2.3-1 - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; uint8_t feedback_ti = - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0]; + ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0]; // set the harq status at MAC for feedback set_harq_status(mac,dci->pucch_resource_indicator, @@ -1143,7 +1236,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_1->accumulated_delta_PUCCH, feedback_ti, dci->dai[0].val, - dci_ind->n_CCE,dci_ind->N_CCE, + dci_ind->n_CCE,dci_ind->N_CCE,0, frame,slot); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; @@ -1151,10 +1244,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->number_pdus = dl_config->number_pdus + 1; /* TODO same calculation for MCS table as done in UL */ - dlsch_config_pdu_1_1->mcs_table = (pdsch_config->mcs_Table) ? (*pdsch_config->mcs_Table + 1) : 0; + dlsch_config_pdu_1_1->mcs_table = (pdsch_Config->mcs_Table) ? (*pdsch_Config->mcs_Table + 1) : 0; /*PTRS configuration */ - if(mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { - valid_ptrs_setup = set_dl_ptrs_values(mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup, + if(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { + valid_ptrs_setup = set_dl_ptrs_values(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup, dlsch_config_pdu_1_1->number_rbs, dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table, &dlsch_config_pdu_1_1->PTRSFreqDensity,&dlsch_config_pdu_1_1->PTRSTimeDensity, &dlsch_config_pdu_1_1->PTRSPortIndex,&dlsch_config_pdu_1_1->nEpreRatioOfPDSCHToPTRS, @@ -1213,6 +1306,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, uint8_t dai, int n_CCE, int N_CCE, + int is_common, frame_t frame, int slot) { @@ -1222,6 +1316,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, current_harq->ack_received = false; current_harq->pucch_resource_indicator = pucch_id; current_harq->feedback_to_ul = data_toul_fb; + current_harq->is_common = is_common; current_harq->dai = dai; current_harq->n_CCE = n_CCE; current_harq->N_CCE = N_CCE; @@ -1230,6 +1325,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, current_harq->dl_frame = frame; current_harq->dl_slot = slot; + LOG_D(PHY,"Setting harq_status for harq_id %d, dl %d.%d\n",harq_id,frame,slot); } @@ -1242,6 +1338,8 @@ void update_harq_status(nr_downlink_indication_t *dl_info, int pdu_id) { if (current_harq->active) { current_harq->ack = dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack; current_harq->ack_received = true; + LOG_D(PHY,"Updating harq_status for harq_id %d,ack/nak %d\n",harq_pid,current_harq->ack); + } else { //shouldn't get here @@ -1283,6 +1381,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->rnti = rnti; + LOG_D(NR_MAC,"initial_pucch_id %d, pucch_resource %p\n",pucch->initial_pucch_id,pucch->pucch_resource); // configure pucch from Table 9.2.1-1 if (pucch->initial_pucch_id > -1 && pucch->pucch_resource == NULL) { @@ -1345,7 +1444,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, mac->cg->physicalCellGroupConfig && (mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL || mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) { - LOG_E(PHY,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); return; } else if (mac->cg && @@ -1388,33 +1487,6 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, } else AssertFatal(1==0,"no pucch_Config\n"); - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; - if (mac->scc) pucch_ConfigCommon = mac->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; - else pucch_ConfigCommon = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; - if (pucch_ConfigCommon->hoppingId != NULL) - pucch_pdu->hopping_id = *pucch_ConfigCommon->hoppingId; - else - pucch_pdu->hopping_id = mac->physCellId; - - switch (pucch_ConfigCommon->pucch_GroupHopping){ - case 0 : - // if neither, both disabled - pucch_pdu->group_hop_flag = 0; - pucch_pdu->sequence_hop_flag = 0; - break; - case 1 : - // if enable, group enabled - pucch_pdu->group_hop_flag = 1; - pucch_pdu->sequence_hop_flag = 0; - break; - case 2 : - // if disable, sequence disabled - pucch_pdu->group_hop_flag = 0; - pucch_pdu->sequence_hop_flag = 1; - break; - default: - AssertFatal(1==0,"Group hopping flag undefined (0,1,2) \n"); - } pucch_pdu->prb_start = pucchres->startingPRB; pucch_pdu->freq_hop_flag = pucchres->intraSlotFrequencyHopping!= NULL ? 1 : 0; @@ -1516,6 +1588,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, default : AssertFatal(1==0,"Undefined PUCCH format \n"); } + pucch_pdu->pucch_tx_power = get_pucch_tx_power_ue(mac, pucch_Config, pucch, @@ -1523,11 +1596,47 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->prb_size, pucch_pdu->freq_hop_flag, pucch_pdu->add_dmrs_flag, - pucch_pdu->nr_of_symbols, - subframe_number, - O_ACK, O_SR, - O_CSI, O_CRC); + pucch_pdu->nr_of_symbols, + subframe_number, + O_ACK, O_SR, + O_CSI, O_CRC); } + else AssertFatal(1==0,"problem with pucch configuration\n"); + + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; + if (bwp_id>0 && + mac->ULbwp[bwp_id-1] && + mac->ULbwp[bwp_id-1]->bwp_Common && + mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon) + pucch_ConfigCommon = mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup; + else if (mac->scc) pucch_ConfigCommon = mac->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + else pucch_ConfigCommon = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; + if (pucch_ConfigCommon->hoppingId != NULL) + pucch_pdu->hopping_id = *pucch_ConfigCommon->hoppingId; + else + pucch_pdu->hopping_id = mac->physCellId; + + switch (pucch_ConfigCommon->pucch_GroupHopping){ + case 0 : + // if neither, both disabled + pucch_pdu->group_hop_flag = 0; + pucch_pdu->sequence_hop_flag = 0; + break; + case 1 : + // if enable, group enabled + pucch_pdu->group_hop_flag = 1; + pucch_pdu->sequence_hop_flag = 0; + break; + case 2 : + // if disable, sequence disabled + pucch_pdu->group_hop_flag = 0; + pucch_pdu->sequence_hop_flag = 1; + break; + default: + AssertFatal(1==0,"Group hopping flag undefined (0,1,2) \n"); + } + + } @@ -1761,7 +1870,8 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; int n_list; - if ((bwp_id == 0 && + if (pucch->is_common == 1 || + (bwp_id == 0 && mac->cg == NULL) || (bwp_id == 0 && mac->cg && @@ -1881,33 +1991,26 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, int V_DAI_m_DL = 0; NR_UE_HARQ_STATUS_t *current_harq; int sched_frame,sched_slot; - NR_BWP_UplinkCommon_t *initialUplinkBWP; - if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; int slots_per_frame,scs; - if (mac->DLbwp[0] && - mac->DLbwp[0]->bwp_Dedicated && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0] == 2) { + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_DownlinkDedicated_t *bwpd=NULL; + NR_BWP_DownlinkCommon_t *bwpc=NULL; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_BWP_UplinkCommon_t *ubwpc=NULL; + get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); + + if (bwpd && + bwpd->pdsch_Config && + bwpd->pdsch_Config->choice.setup && + bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI && + bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0] == 2) { two_transport_blocks = TRUE; number_of_code_word = 2; } - else { - number_of_code_word = 1; - } - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; - if (mac->cg && ubwp && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; - } - else - scs = initialUplinkBWP->genericParameters.subcarrierSpacing; + scs = ubwpc->genericParameters.subcarrierSpacing; slots_per_frame = nr_slots_per_frame[scs]; @@ -1926,7 +2029,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, sched_slot %= slots_per_frame; sched_frame++; } - + LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common); /* check if current tx slot should transmit downlink acknowlegment */ if (sched_frame == frame && sched_slot == slot) { @@ -1959,6 +2062,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, pucch->n_CCE = current_harq->n_CCE; pucch->N_CCE = current_harq->N_CCE; pucch->delta_pucch = current_harq->delta_pucch; + pucch->is_common = current_harq->is_common; current_harq->active = false; current_harq->ack_received = false; } @@ -1986,7 +2090,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, if (mac->cg != NULL && mac->cg->physicalCellGroupConfig != NULL && mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL) { - int N_TB_max_DL = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0]; + int N_TB_max_DL = bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0]; pucch->n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c; NR_TST_PHY_PRINTF("PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", pucch->n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx); } @@ -2111,7 +2215,9 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - if(!pucch_Config || pucch_Config->schedulingRequestResourceToAddModList->list.count==0) + if(!pucch_Config || + !pucch_Config->schedulingRequestResourceToAddModList || + pucch_Config->schedulingRequestResourceToAddModList->list.count==0) return false; // SR not configured for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { @@ -2145,9 +2251,54 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, return false; } +int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot){ + // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti + DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_NR_UE_MAC_INST, 0); + NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + DSR_TRANSMAX_t dsr_TransMax = sr_n64; // todo + LOG_D(NR_MAC, "[UE %d] Frame %d slot %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP, frameP, slot, + mac->scheduling_info.SR_COUNTER, + (1 << (2 + dsr_TransMax)), + mac->scheduling_info.SR_pending); // todo -int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, int slotP){ - return 0; + if ((mac->scheduling_info.SR_pending == 1) && + (mac->scheduling_info.SR_COUNTER < (1 << (2 + dsr_TransMax)))) { + LOG_D(NR_MAC, "[UE %d] Frame %d slot %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d, increment SR_COUNTER\n", + module_idP, frameP, slot, + mac->scheduling_info.SR_COUNTER, + (1 << (2 + dsr_TransMax)), + mac->scheduling_info.SR_pending); // todo + mac->scheduling_info.SR_COUNTER++; + + // start the sr-prohibittimer : rel 9 and above + if (mac->scheduling_info.sr_ProhibitTimer > 0) { // timer configured + mac->scheduling_info.sr_ProhibitTimer--; + mac->scheduling_info. + sr_ProhibitTimer_Running = 1; + } else { + mac->scheduling_info. + sr_ProhibitTimer_Running = 0; + } + //mac->ul_active =1; + return (1); //instruct phy to signal SR + } else { + // notify RRC to relase PUCCH/SRS + // clear any configured dl/ul + // initiate RA + if (mac->scheduling_info.SR_pending) { + // release all pucch resource + //mac->physicalConfigDedicated = NULL; // todo + //mac->ul_active = 0; // todo + mac->BSR_reporting_active = + NR_BSR_TRIGGER_NONE; + LOG_I(NR_MAC, "[UE %d] Release all SRs \n", module_idP); + } + + mac->scheduling_info.SR_pending = 0; + mac->scheduling_info.SR_COUNTER = 0; + return (0); + } } @@ -2453,7 +2604,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case NR_RNTI_RA: if(mac->scc_SIB) { - N_RB = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + N_RB = mac->type0_PDCCH_CSS_config.num_rbs; } else { N_RB = get_n_rb(mac, rnti_type); } @@ -2691,7 +2842,8 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // check BWP id if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + else N_RB=mac->type0_PDCCH_CSS_config.num_rbs; +; // indicating a DL DCI format 1bit pos++; @@ -3151,7 +3303,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, frame_t frameP = dl_info->frame; int slot = dl_info->slot; uint8_t *pduP = (dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu; - int16_t pdu_len = (int16_t)(dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu_length; + int32_t pdu_len = (int32_t)(dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu_length; uint8_t gNB_index = dl_info->gNB_index; uint8_t CC_id = dl_info->cc_id; uint8_t done = 0; @@ -3309,7 +3461,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, #endif */ - LOG_D(MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d\n", frameP, slot, ul_time_alignment->ta_command, ul_time_alignment->tag_id, CC_id); + LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d\n", frameP, slot, ul_time_alignment->ta_command, ul_time_alignment->tag_id, CC_id); break; case DL_SCH_LCID_CON_RES_ID: @@ -3408,13 +3560,17 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, * Return: number of written bytes */ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, - NR_UE_MAC_INST_t *mac) { + NR_UE_MAC_INST_t *mac, + uint8_t power_headroom, // todo: NR_POWER_HEADROOM_CMD *power_headroom, + uint16_t *crnti, + NR_BSR_SHORT *truncated_bsr, + NR_BSR_SHORT *short_bsr, + NR_BSR_LONG *long_bsr) { int mac_ce_len = 0; uint8_t mac_ce_size = 0; - NR_UE_MAC_CE_t *nr_ue_mac_ce = &mac->nr_ue_mac_ce; - - if (nr_ue_mac_ce->phr_reporting && mac->phr_Config != NULL) { + uint8_t *pdu = mac_ce; + if (power_headroom) { // MAC CE fixed subheader ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0; @@ -3422,21 +3578,22 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, mac_ce++; // PHR MAC CE (1 octet) - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = 0; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = power_headroom; ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R1 = 0; - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = 0; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = 0; // todo ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R2 = 0; // update pointer and length mac_ce_size = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); - + LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : power_headroom pdu %p mac_ce %p b\n", + pdu, mac_ce); } - if (!get_softmodem_params()->sa && get_softmodem_params()->do_ra && mac->ra.ra_state != RA_SUCCEEDED) { + if (crnti && (!get_softmodem_params()->sa && get_softmodem_params()->do_ra && mac->ra.ra_state != RA_SUCCEEDED)) { - LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, mac->crnti); + LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, (*crnti)); // MAC CE fixed subheader ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0; @@ -3444,7 +3601,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, mac_ce++; // C-RNTI MAC CE (2 octets) - *(uint16_t *) mac_ce = mac->crnti; + *(uint16_t *) mac_ce = (*crnti); // update pointer and length mac_ce_size = sizeof(uint16_t); @@ -3453,55 +3610,110 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, } - if (nr_ue_mac_ce->truncated_bsr) { + if (truncated_bsr) { - LOG_D(NR_MAC, "In %s: generating short truncated BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->truncated_bsr); - - // MAC CE fixed subheader + // MAC CE fixed subheader ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->LCID = UL_SCH_LCID_S_TRUNCATED_BSR; mac_ce++; // Short truncated BSR MAC CE (1 octet) - ((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> Buffer_size = 0; - ((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> LcgID = 0; + ((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> Buffer_size = truncated_bsr->Buffer_size; + ((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> LcgID = truncated_bsr->LcgID;; // update pointer and length mac_ce_size = sizeof(NR_BSR_SHORT_TRUNCATED); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); + LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : truncated_bsr Buffer_size %d LcgID %d pdu %p mac_ce %p\n", + truncated_bsr->Buffer_size, truncated_bsr->LcgID, pdu, mac_ce); - } else if (nr_ue_mac_ce->short_bsr) { + } else if (short_bsr) { - LOG_D(NR_MAC, "In %s: generating short BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->short_bsr); - - // MAC CE fixed subheader + // MAC CE fixed subheader ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->LCID = UL_SCH_LCID_S_BSR; mac_ce++; // Short truncated BSR MAC CE (1 octet) - ((NR_BSR_SHORT *) mac_ce)->Buffer_size = nr_ue_mac_ce->short_bsr; - ((NR_BSR_SHORT *) mac_ce)->LcgID = 0; + ((NR_BSR_SHORT *) mac_ce)->Buffer_size = short_bsr->Buffer_size; + ((NR_BSR_SHORT *) mac_ce)->LcgID = short_bsr->LcgID; // update pointer and length mac_ce_size = sizeof(NR_BSR_SHORT); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); + LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : short_bsr Buffer_size %d LcgID %d pdu %p mac_ce %p\n", + short_bsr->Buffer_size, short_bsr->LcgID, pdu, mac_ce); + } else if (long_bsr) { - } else if (nr_ue_mac_ce->long_bsr) { - // MAC CE variable subheader - // todo ch 6.1.3.1. TS 38.321 - // ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->R = 0; - // ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->F = 0; - // ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->LCID = UL_SCH_LCID_L_BSR; - // ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->L = 0; - // sh_size = 2; + // MAC CE variable subheader + // ch 6.1.3.1. TS 38.321 + ((NR_MAC_SUBHEADER_SHORT *) mac_ce)->R = 0; + ((NR_MAC_SUBHEADER_SHORT *) mac_ce)->F = 0; + ((NR_MAC_SUBHEADER_SHORT *) mac_ce)->LCID = UL_SCH_LCID_L_BSR; - // Short truncated BSR MAC CE (1 octet) - // ((NR_BSR_LONG *) mac_ce)->Buffer_size0 = short_bsr; - // ((NR_BSR_LONG *) mac_ce)->LCGID0 = 0; - // mac_ce_size = sizeof(NR_BSR_LONG); // size is variable + NR_MAC_SUBHEADER_SHORT *mac_pdu_subheader_ptr = (NR_MAC_SUBHEADER_SHORT *) mac_ce; + mac_ce += 2; + + // Could move to nr_get_sdu() + uint8_t *Buffer_size_ptr= (uint8_t*) mac_ce + 1; + //int NR_BSR_LONG_SIZE = 1; + if (long_bsr->Buffer_size0 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID0 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID0 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size0; + } + if (long_bsr->Buffer_size1 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID1 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID1 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size1; + } + if (long_bsr->Buffer_size2 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID2 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID2 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size2; + } + if (long_bsr->Buffer_size3 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID3 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID3 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size3; + } + if (long_bsr->Buffer_size4 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID4 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID4 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size4; + } + if (long_bsr->Buffer_size5 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID5 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID5 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size5; + } + if (long_bsr->Buffer_size6 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID6 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID6 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size6; + } + if (long_bsr->Buffer_size7 == 0) { + ((NR_BSR_LONG *) mac_ce)->LcgID7 = 0; + } else { + ((NR_BSR_LONG *) mac_ce)->LcgID7 = 1; + *Buffer_size_ptr++ = long_bsr->Buffer_size7; + } + ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_subheader_ptr)->L = mac_ce_size = (uint8_t*) Buffer_size_ptr - (uint8_t*) mac_ce; + LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : long_bsr size %d Lcgbit 0x%02x Buffer_size %d %d %d %d %d %d %d %d\n", mac_ce_size, *((uint8_t*) mac_ce), + ((NR_BSR_LONG *) mac_ce)->Buffer_size0, ((NR_BSR_LONG *) mac_ce)->Buffer_size1, ((NR_BSR_LONG *) mac_ce)->Buffer_size2, ((NR_BSR_LONG *) mac_ce)->Buffer_size3, + ((NR_BSR_LONG *) mac_ce)->Buffer_size4, ((NR_BSR_LONG *) mac_ce)->Buffer_size5, ((NR_BSR_LONG *) mac_ce)->Buffer_size6, ((NR_BSR_LONG *) mac_ce)->Buffer_size7); + // update pointer and length + mac_ce = Buffer_size_ptr; + mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_SHORT); } return mac_ce_len; @@ -3553,8 +3765,6 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t return 0; } - int cc_id = dl_info->cc_id; - uint8_t gNB_id = dl_info->gNB_index; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; uint8_t n_subPDUs = 0; // number of RAR payloads @@ -3566,7 +3776,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t int ret = 0; NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer; // RAR subheader pointer NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer - uint8_t preamble_index = get_ra_PreambleIndex(mod_id, cc_id, gNB_id); //prach_resources->ra_PreambleIndex; + uint8_t preamble_index = ra->ra_PreambleIndex; LOG_D(NR_MAC, "In %s:[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", __FUNCTION__, frame, slot, mod_id, preamble_index); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index f3a2496ce3..f813efad92 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -53,6 +53,8 @@ #include +#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" + static prach_association_pattern_t prach_assoc_pattern; static ssb_list_info_t ssb_list; @@ -164,13 +166,26 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { NR_ServingCellConfigCommon_t *scc = mac->scc; - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) + ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + + NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0] ? + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : + (ubwpd? + ubwpd->pusch_Config->choice.setup: + NULL); long transformPrecoder; - if (pusch_Config->transformPrecoder) + if (pusch_Config && pusch_Config->transformPrecoder) transformPrecoder = *pusch_Config->transformPrecoder; else { - if(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder) + if(scc && scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder) transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; else transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; @@ -301,10 +316,20 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { /* ANTENNA_PORTS */ - uint8_t rank = 0; // We need to initialize rank FIXME!!! + uint8_t rank = 1; // We need to initialize rank FIXME!!! NR_ServingCellConfigCommon_t *scc = mac->scc; - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) + ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + + NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0] ? mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); + AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); long transformPrecoder; if (pusch_Config->transformPrecoder) @@ -317,6 +342,8 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf } long *max_length = NULL; long *dmrs_type = NULL; + LOG_D(NR_MAC,"transformPrecoder %s\n",transformPrecoder==NR_PUSCH_Config__transformPrecoder_disabled?"disabled":"enabled"); + if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA) { max_length = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->maxLength; dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->dmrs_Type; @@ -326,7 +353,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->dmrs_Type; } - + LOG_D(NR_MAC,"MappingType%s max_length %s, dmrs_type %s, antenna_ports %d\n",pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA?"A":"B",max_length?"len2":"len1",dmrs_type?"type2":"type1",dci->antenna_ports.val); if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) && (dmrs_type == NULL) && (max_length == NULL)) { // tables 7.3.1.1.2-6 pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC @@ -481,6 +508,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf //pusch_config_pdu->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports.val][5]; //FIXME } } + LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, dmrs_ports %d\n",pusch_config_pdu->num_dmrs_cdm_grps_no_data,pusch_config_pdu->dmrs_ports); } // Configuration of Msg3 PDU according to clauses: @@ -626,22 +654,23 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->pusch_data.num_cb = 0; } else if (dci) { + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_DownlinkDedicated_t *bwpd=NULL; + NR_BWP_DownlinkCommon_t *bwpc=NULL; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_BWP_UplinkCommon_t *ubwpc=NULL; + get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); int target_ss; bool valid_ptrs_setup = 0; uint16_t n_RB_ULBWP; - if (mac->ULbwp[0] && mac->ULbwp[0]->bwp_Common) { - n_RB_ULBWP = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - else { - pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - n_RB_ULBWP = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - + n_RB_ULBWP = NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pusch_config_pdu->bwp_size = n_RB_ULBWP; - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0] ? mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : NULL; + AssertFatal(ubwpd->pusch_Config != NULL,"pusch_Config shouldn't be null\n"); + NR_PUSCH_Config_t *pusch_Config = ubwpd->pusch_Config->choice.setup; // Basic sanity check for MCS value to check for a false or erroneous DCI if (dci->mcs > 28) { @@ -661,12 +690,9 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } else if (*dci_format == NR_UL_DCI_FORMAT_0_1) { - /* BANDWIDTH_PART_IND */ - if (dci->bwp_indicator.val != 1) { - LOG_W(NR_MAC, "bwp_indicator != 1! Possibly due to false DCI. Ignoring DCI!\n"); - return -1; - } config_bwp_ue(mac, &dci->bwp_indicator.val, dci_format); + get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; ul_layers_config(mac, pusch_config_pdu, dci); ul_ports_config(mac, pusch_config_pdu, dci); @@ -677,21 +703,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, return -1; } - - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (pusch_Config && pusch_Config->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = pusch_Config->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common&& - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon&& - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - else if (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) - pusch_TimeDomainAllocationList=mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - else AssertFatal(1==0,"need to fall back to default PUSCH time-domain allocations\n"); + NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon = ubwpc->pusch_ConfigCommon->choice.setup; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = choose_ul_tda_list(pusch_Config,pusch_ConfigCommon); int mappingtype = pusch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; @@ -735,7 +748,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, return -1; } /* TIME_DOM_RESOURCE_ASSIGNMENT */ - if (nr_ue_process_dci_time_dom_resource_assignment(mac, pusch_config_pdu, NULL, dci->time_domain_assignment.val,0,false) < 0) { + if (nr_ue_process_dci_time_dom_resource_assignment(mac, pusch_TimeDomainAllocationList, NULL, pusch_config_pdu, NULL, dci->time_domain_assignment.val,0,false) < 0) { return -1; } @@ -842,7 +855,14 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, return -1; } - get_num_re_dmrs(pusch_config_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols); + int start_symbol = pusch_config_pdu->start_symbol_index; + int number_of_symbols = pusch_config_pdu->nr_of_symbols; + for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { + if((pusch_config_pdu->ul_dmrs_symb_pos >> i) & 0x01) + number_dmrs_symbols += 1; + } + + nb_dmrs_re_per_rb = ((pusch_config_pdu->dmrs_config_type == pusch_dmrs_type1) ? 6:4)*pusch_config_pdu->num_dmrs_cdm_grps_no_data; // Compute TBS pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order, @@ -940,11 +960,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) { uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size; - LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d\n", + LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d (ra_state %d)\n", ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id, mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id], ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator, - TBS_bytes); + TBS_bytes,ra->ra_state); if (ra->ra_state == WAIT_RAR && !ra->cfra){ memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes); LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n"); @@ -963,7 +983,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in (ra->ra_state == WAIT_RAR && ra->cfra))){ // Getting IP traffic to be transmitted - nr_ue_get_sdu(mod_id, frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes); + nr_ue_get_sdu(mod_id, cc_id,frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes); } LOG_D(NR_MAC,"Flipping NDI for harq_id %d\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator); @@ -999,10 +1019,324 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } } + if (dl_info) { + return (CONNECTION_OK); + } + module_id_t mod_id = ul_info->module_id; + frame_t txFrameP = ul_info->frame_tx; + slot_t txSlotP = ul_info->slot_tx; + + // Handle the SR/BSR procedures per subframe + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + uint8_t gNB_indexP=0; + + // Call BSR procedure as described in Section 5.4.5 in 38.321 + + // First check ReTxBSR Timer because it is always configured + // Decrement ReTxBSR Timer if it is running and not null + if ((mac->scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) && (mac->scheduling_info.retxBSR_SF != 0)) { + mac->scheduling_info.retxBSR_SF--; + } + + // Decrement Periodic Timer if it is running and not null + if ((mac->scheduling_info.periodicBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) && (mac->scheduling_info.periodicBSR_SF != 0)) { + mac->scheduling_info.periodicBSR_SF--; + } + + //Check whether Regular BSR is triggered + if (nr_update_bsr(mod_id, txFrameP, txSlotP, gNB_indexP) == TRUE) { + // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures + // outlined in Sections 5.4.4 an 5.4.5 of 38.321 + mac->scheduling_info.SR_pending = 1; + // Regular BSR trigger + mac->BSR_reporting_active |= NR_BSR_TRIGGER_REGULAR; + LOG_D(NR_MAC, "[UE %d][BSR] Regular BSR Triggered Frame %d slot %d SR for PUSCH is pending\n", + mod_id, txFrameP, txSlotP); + } return UE_CONNECTION_OK; } +boolean_t +nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index) { + mac_rlc_status_resp_t rlc_status; + boolean_t bsr_regular_triggered = FALSE; + uint8_t lcid; + uint8_t lcgid; + uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined + uint32_t lcgid_buffer_remain[NR_MAX_NUM_LCGID] = {0,0,0,0,0,0,0,0}; + int32_t lcid_bytes_in_buffer[NR_MAX_NUM_LCID]; + /* Array for ordering LCID with data per decreasing priority order */ + uint8_t lcid_reordered_array[NR_MAX_NUM_LCID]= + {NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID, + NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID, + NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID, + NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID,NR_MAX_NUM_LCID, + }; + uint8_t pos_next = 0; + //uint8_t highest_priority = 16; + uint8_t array_index = 0; + // Reset All BSR Infos + lcid_bytes_in_buffer[0] = 0; + NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + for (lcid=DCCH; lcid < NR_MAX_NUM_LCID; lcid++) { + // Reset transmission status + lcid_bytes_in_buffer[lcid] = 0; + mac->scheduling_info.LCID_status[lcid]=LCID_EMPTY; + } + + for (lcgid=0; lcgid < NR_MAX_NUM_LCGID; lcgid++) { + // Reset Buffer Info + mac->scheduling_info.BSR[lcgid]=0; + mac->scheduling_info.BSR_bytes[lcgid]=0; + } + + //Get Buffer Occupancy and fill lcid_reordered_array + for (lcid=DCCH; lcid < NR_MAX_NUM_LCID; lcid++) { + //if (mac->logicalChannelConfig[lcid]) { + if (mac->logicalChannelBearer_exist[lcid] ) { // todo + lcgid = mac->scheduling_info.LCGID[lcid]; + + // Store already available data to transmit per Group + if (lcgid < NR_MAX_NUM_LCGID) { + lcgid_buffer_remain[lcgid] += mac->scheduling_info.LCID_buffer_remain[lcid]; + } + + rlc_status = mac_rlc_status_ind(module_idP, mac->crnti,gNB_index,frameP,slotP,ENB_FLAG_NO,MBMS_FLAG_NO, lcid, 0, 0); + + lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(NR_MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d slot %d\n", + module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,slotP); + mac->scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; + + //Update BSR_bytes and position in lcid_reordered_array only if Group is defined + if (lcgid < NR_MAX_NUM_LCGID) { + num_lcid_with_data ++; + // sum lcid buffer which has same lcgid + mac->scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer; + //Fill in the array + array_index = 0; + + do { + //if (mac->logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority) { + if (1) { // todo + //Insert if priority is higher or equal (lower or equal in value) + for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--) { + lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1]; + } + + lcid_reordered_array[array_index] = lcid; + break; + } + + array_index ++; + } while ((array_index < num_lcid_with_data) && (array_index < NR_MAX_NUM_LCID)); + } + } + } + } + + // Check whether a regular BSR can be triggered according to the first cases in 38.321 + if (num_lcid_with_data) { + LOG_D(NR_MAC, "[UE %d] PDCCH Tick at frame %d slot %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", + module_idP, frameP, slotP, num_lcid_with_data, + lcid_reordered_array[0], lcid_reordered_array[1], + lcid_reordered_array[2]); + + for (array_index = 0; array_index < num_lcid_with_data; array_index++) { + lcid = lcid_reordered_array[array_index]; + + /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity + either the data belongs to a logical channel with higher priority than the priorities of the logical channels + which belong to any LCG and for which data is already available for transmission + */ + { + bsr_regular_triggered = TRUE; + LOG_D(NR_MAC, "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d slot %d\n", + module_idP, lcid, + mac->scheduling_info.LCGID[lcid], + frameP, slotP); + break; + } + } + + // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission + if (mac->scheduling_info.retxBSR_SF == 0) { + bsr_regular_triggered = TRUE; + + if ((mac->BSR_reporting_active & NR_BSR_TRIGGER_REGULAR) == 0) { + LOG_I(NR_MAC, "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d slot %d\n", + module_idP, frameP, slotP); + } + } + } + + //Store Buffer Occupancy in remain buffers for next TTI + for (lcid = DCCH; lcid < NR_MAX_NUM_LCID; lcid++) { + mac->scheduling_info.LCID_buffer_remain[lcid] = lcid_bytes_in_buffer[lcid]; + } + + return bsr_regular_triggered; +} + +uint8_t +nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size, int value) { + uint8_t ju, jm, jl; + int ascend; + //DevAssert(size > 0); + //DevAssert(size <= 256); + + if (value == 0) { + return 0; //elseif (value > 150000) return 63; + } + + jl = 0; // lower bound + ju = size - 1; // upper bound + ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise + + while (ju - jl > 1) { //If we are not yet done, + jm = (ju + jl) >> 1; //compute a midpoint, + + if ((value >= table[jm]) == ascend) { + jl = jm; // replace the lower limit + } else { + ju = jm; //replace the upper limit + } + + LOG_T(NR_MAC, "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", + jm, table[jm], value); + } + + if (value == table[jl]) { + return jl; + } else { + return jl + 1; //equally ju + } +} + +int nr_get_sf_periodicBSRTimer(uint8_t sf_offset) { + switch (sf_offset) { + case NR_BSR_Config__periodicBSR_Timer_sf1: + return 1; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf5: + return 5; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf10: + return 10; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf16: + return 16; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf20: + return 20; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf32: + return 32; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf40: + return 40; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf64: + return 64; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf80: + return 80; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf128: + return 128; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf160: + return 160; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf320: + return 320; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf640: + return 640; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf1280: + return 1280; + break; + + case NR_BSR_Config__periodicBSR_Timer_sf2560: + return 2560; + break; + + case NR_BSR_Config__periodicBSR_Timer_infinity: + default: + return 0xFFFF; + break; + } +} + +int nr_get_sf_retxBSRTimer(uint8_t sf_offset) { + switch (sf_offset) { + case NR_BSR_Config__retxBSR_Timer_sf10: + return 10; + break; + + case NR_BSR_Config__retxBSR_Timer_sf20: + return 20; + break; + + case NR_BSR_Config__retxBSR_Timer_sf40: + return 40; + break; + + case NR_BSR_Config__retxBSR_Timer_sf80: + return 80; + break; + + case NR_BSR_Config__retxBSR_Timer_sf160: + return 160; + break; + + case NR_BSR_Config__retxBSR_Timer_sf320: + return 320; + break; + + case NR_BSR_Config__retxBSR_Timer_sf640: + return 640; + break; + + case NR_BSR_Config__retxBSR_Timer_sf1280: + return 1280; + break; + + case NR_BSR_Config__retxBSR_Timer_sf2560: + return 2560; + break; + + case NR_BSR_Config__retxBSR_Timer_sf5120: + return 5120; + break; + + case NR_BSR_Config__retxBSR_Timer_sf10240: + return 10240; + break; + + default: + return -1; + break; + } +} + // PUSCH scheduler: // - Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, // - where K2 is the offset between the slot in which UL DCI is received and the slot @@ -1066,6 +1400,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, // Get slot offset K2 which will be used to calculate TX slot k2 = get_k2(mac, tda_id); if (k2 < 0) { // This can happen when a false DCI is received + LOG_W(PHY,"%d.%d. Received k2 %d, tda_id %d\n",current_frame,current_slot,k2,tda_id); return -1; } @@ -1816,6 +2151,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, in pucch, pucch_pdu, O_SR, O_ACK, O_CSI); + LOG_D(NR_MAC,"Configuring pucch, is_common = %d\n",pucch->is_common); fill_ul_config(ul_config, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PUCCH); nr_scheduled_response_t scheduled_response; fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id); @@ -1978,7 +2314,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); nr_scheduled_response_t scheduled_response; - int frame_s,slot_s,ret; + int frame_s,slot_s; fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15; @@ -1993,6 +2329,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, ssb_start_symbol, scs_ssb, frequency_range, + mac->nr_band, ssb_index, 1, // If the UE is not configured with a periodicity, the UE assumes a periodicity of a half frame ssb_offset_point_a); @@ -2000,33 +2337,29 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, if(mac->search_space_zero == NULL) mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); if(mac->coreset0 == NULL) mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); - for (int i=0; i<3; i++) { // loop over possible aggregation levels + fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); + fill_searchSpaceZero(mac->search_space_zero, &mac->type0_PDCCH_CSS_config); + rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; + rel15->num_dci_options = 1; + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); + fill_dci_search_candidates(mac->search_space_zero, rel15); - fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); - ret = fill_searchSpaceZero(mac->search_space_zero, &mac->type0_PDCCH_CSS_config,4<dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(mac->search_space_zero, rel15); - - if(mac->type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern == 1){ - // same frame as ssb - if ((mac->type0_PDCCH_CSS_config.frame & 0x1) == mac->type0_PDCCH_CSS_config.sfn_c) - frame_s = 0; - else - frame_s = 1; - slot_s = mac->type0_PDCCH_CSS_config.n_0; - } - else{ - frame_s = 0; // same frame as ssb - slot_s = mac->type0_PDCCH_CSS_config.n_c; - } - LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus); - fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0); // TODO fix thread_id, for now assumed 0 - } + if(mac->type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern == 1){ + // same frame as ssb + if ((mac->type0_PDCCH_CSS_config.frame & 0x1) == mac->type0_PDCCH_CSS_config.sfn_c) + frame_s = 0; + else + frame_s = 1; + slot_s = mac->type0_PDCCH_CSS_config.n_0; } + else{ + frame_s = 0; // same frame as ssb + slot_s = mac->type0_PDCCH_CSS_config.n_c; + } + LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus); + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0); // TODO fix thread_id, for now assumed 0 + if (dl_config->number_pdus) { if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); @@ -2037,12 +2370,268 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, #define MAX_LCID 8 // NR_MAX_NUM_LCID shall be used but the mac_rlc_data_req function can fetch data for max 8 LCID +typedef struct { + uint8_t bsr_len; + uint8_t bsr_ce_len; + uint8_t bsr_header_len; + uint8_t phr_len; + uint8_t phr_ce_len; + uint8_t phr_header_len; + uint16_t sdu_length_total; + NR_BSR_SHORT *bsr_s; + NR_BSR_LONG *bsr_l; + NR_BSR_SHORT *bsr_t; + //NR_POWER_HEADROOM_CMD *phr_pr; + int tot_mac_ce_len; + uint8_t total_mac_pdu_header_len; +} NR_UE_MAC_CE_INFO; + +/* +nr_ue_get_sdu_mac_ce_pre finds length in various mac_ce field +Need nothing from mac_ce_p: +Update the following in mac_ce_p: + bsr_len; + bsr_ce_len; + bsr_header_len; + phr_len; TBD + phr_ce_len; TBD + phr_header_len; TBD +*/ +int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP, + int CC_id, + frame_t frameP, + sub_frame_t subframe, + uint8_t gNB_index, + uint8_t *ulsch_buffer, + uint16_t buflen, + NR_UE_MAC_CE_INFO *mac_ce_p) { + NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + + int num_lcg_id_with_data = 0; + // Preparing the MAC CEs sub-PDUs and get the total size + mac_ce_p->bsr_header_len = 0; + mac_ce_p->phr_header_len = 0; //sizeof(SCH_SUBHEADER_FIXED); + int lcg_id = 0; + while (lcg_id < NR_MAX_NUM_LCGID) { + if (mac->scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; + } + + lcg_id++; + } + + //Restart ReTxBSR Timer at new grant indication (38.321) + if (mac->scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) { + mac->scheduling_info.retxBSR_SF = nr_get_sf_retxBSRTimer(mac->scheduling_info.retxBSR_Timer); + } + + // periodicBSR-Timer expires, trigger BSR + if ((mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity) + && (mac->scheduling_info.periodicBSR_SF == 0)) { + // Trigger BSR Periodic + mac->BSR_reporting_active |= NR_BSR_TRIGGER_PERIODIC; + LOG_D(NR_MAC, "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + } + + //Compute BSR Length if Regular or Periodic BSR is triggered + //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx + if (mac->BSR_reporting_active) { + AssertFatal((mac->BSR_reporting_active & NR_BSR_TRIGGER_PADDING) == 0, + "Inconsistent BSR Trigger=%d !\n", + mac->BSR_reporting_active); + + //A Regular or Periodic BSR can only be sent if TBS is sufficient as transmitting only a BSR is not allowed if UE has data to transmit + if (num_lcg_id_with_data <= 1) { + if (buflen >= (sizeof(NR_BSR_SHORT)+sizeof(NR_MAC_SUBHEADER_FIXED)+1)) { + mac_ce_p->bsr_ce_len = sizeof(NR_BSR_SHORT); //1 byte + mac_ce_p->bsr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED); //1 byte + } + } else { + if (buflen >= (num_lcg_id_with_data+1+sizeof(NR_MAC_SUBHEADER_SHORT)+1)) { + mac_ce_p->bsr_ce_len = num_lcg_id_with_data + 1; //variable size + mac_ce_p->bsr_header_len = sizeof(NR_MAC_SUBHEADER_SHORT); //2 bytes + } + } + } + + mac_ce_p->bsr_len = mac_ce_p->bsr_ce_len + mac_ce_p->bsr_header_len; + return (mac_ce_p->bsr_len + mac_ce_p->phr_len); +} + +/* +nr_ue_get_sdu_mac_ce_post recalculates length and prepares the mac_ce field +Need the following from mac_ce_p: + bsr_ce_len + bsr_len + sdu_length_total + total_mac_pdu_header_len +Update the following in mac_ce_p: + bsr_ce_len + bsr_header_len + bsr_len + tot_mac_ce_len + total_mac_pdu_header_len + bsr_s + bsr_l + bsr_t +*/ +void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, + int CC_id, + frame_t frameP, + sub_frame_t subframe, + uint8_t gNB_index, + uint8_t *ulsch_buffer, + uint16_t buflen, + NR_UE_MAC_CE_INFO *mac_ce_p) { + NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + + // Compute BSR Values and update Nb LCGID with data after multiplexing + unsigned short padding_len = 0; + uint8_t lcid = 0; + int lcg_id = 0; + int num_lcg_id_with_data = 0; + int lcg_id_bsr_trunc = 0; + for (lcg_id = 0; lcg_id < NR_MAX_NUM_LCGID; lcg_id++) { + if (mac_ce_p->bsr_ce_len == sizeof(NR_BSR_SHORT)) { + mac->scheduling_info.BSR[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_SHORT_BSR_TABLE, NR_SHORT_BSR_TABLE_SIZE, mac->scheduling_info.BSR_bytes[lcg_id]); + } else { + mac->scheduling_info.BSR[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_LONG_BSR_TABLE, NR_LONG_BSR_TABLE_SIZE, mac->scheduling_info.BSR_bytes[lcg_id]); + } + if (mac->scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; + lcg_id_bsr_trunc = lcg_id; + } + } + + // TS 38.321 Section 5.4.5 + // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order + // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 + /* For Padding BSR: + - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: + - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; + - else report Short BSR. + - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. + */ + if (mac_ce_p->sdu_length_total) { + padding_len = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total); + } + + if ((padding_len) && (mac_ce_p->bsr_len == 0)) { + /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */ + if (padding_len >= (num_lcg_id_with_data+1+sizeof(NR_MAC_SUBHEADER_SHORT))) { + mac_ce_p->bsr_ce_len = num_lcg_id_with_data + 1; //variable size + mac_ce_p->bsr_header_len = sizeof(NR_MAC_SUBHEADER_SHORT); //2 bytes + // Trigger BSR Padding + mac->BSR_reporting_active |= NR_BSR_TRIGGER_PADDING; + } else if (padding_len >= (sizeof(NR_BSR_SHORT)+sizeof(NR_MAC_SUBHEADER_FIXED))) { + mac_ce_p->bsr_ce_len = sizeof(NR_BSR_SHORT); //1 byte + mac_ce_p->bsr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED); //1 byte + + if (num_lcg_id_with_data > 1) { + // REPORT SHORT TRUNCATED BSR + //Get LCGID of highest priority LCID with data (todo) + for (lcid = DCCH; lcid < NR_MAX_NUM_LCID; lcid++) { + lcg_id = mac->scheduling_info.LCGID[lcid]; + if ((lcg_id < NR_MAX_NUM_LCGID) && (mac->scheduling_info.BSR_bytes[lcg_id])) { + lcg_id_bsr_trunc = lcg_id; + } + } + } else { + //Report SHORT BSR, clear bsr_t + mac_ce_p->bsr_t = NULL; + } + + // Trigger BSR Padding + mac->BSR_reporting_active |= NR_BSR_TRIGGER_PADDING; + } + + mac_ce_p->bsr_len = mac_ce_p->bsr_header_len + mac_ce_p->bsr_ce_len; + mac_ce_p->tot_mac_ce_len += mac_ce_p->bsr_len; + mac_ce_p->total_mac_pdu_header_len += mac_ce_p->bsr_len; + } + + //Fill BSR Infos + if (mac_ce_p->bsr_ce_len == 0) { + mac_ce_p->bsr_s = NULL; + mac_ce_p->bsr_l = NULL; + mac_ce_p->bsr_t = NULL; + } else if (mac_ce_p->bsr_header_len == sizeof(NR_MAC_SUBHEADER_SHORT)) { + mac_ce_p->bsr_s = NULL; + mac_ce_p->bsr_t = NULL; + mac_ce_p->bsr_l->Buffer_size0 = mac->scheduling_info.BSR[0]; + mac_ce_p->bsr_l->Buffer_size1 = mac->scheduling_info.BSR[1]; + mac_ce_p->bsr_l->Buffer_size2 = mac->scheduling_info.BSR[2]; + mac_ce_p->bsr_l->Buffer_size3 = mac->scheduling_info.BSR[3]; + mac_ce_p->bsr_l->Buffer_size4 = mac->scheduling_info.BSR[4]; + mac_ce_p->bsr_l->Buffer_size5 = mac->scheduling_info.BSR[5]; + mac_ce_p->bsr_l->Buffer_size6 = mac->scheduling_info.BSR[6]; + mac_ce_p->bsr_l->Buffer_size7 = mac->scheduling_info.BSR[7]; + LOG_D(NR_MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report LONG BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d level LCGID4 %d,level LCGID5 %d,level LCGID6 %d,level LCGID7 %d)\n", + module_idP, frameP, subframe, + mac->BSR_reporting_active, + mac->scheduling_info.BSR[0], + mac->scheduling_info.BSR[1], + mac->scheduling_info.BSR[2], + mac->scheduling_info.BSR[3], + mac->scheduling_info.BSR[4], + mac->scheduling_info.BSR[5], + mac->scheduling_info.BSR[6], + mac->scheduling_info.BSR[7]); + } else if (mac_ce_p->bsr_header_len == sizeof(NR_MAC_SUBHEADER_FIXED)) { + mac_ce_p->bsr_l = NULL; + + if ((mac_ce_p->bsr_t != NULL) && (mac->BSR_reporting_active & NR_BSR_TRIGGER_PADDING)) { + //Truncated BSR + mac_ce_p->bsr_s = NULL; + mac_ce_p->bsr_t->LcgID = lcg_id_bsr_trunc; + mac_ce_p->bsr_t->Buffer_size = mac->scheduling_info.BSR[lcg_id_bsr_trunc]; + LOG_D(NR_MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + mac->BSR_reporting_active, + mac->scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); + } else { + mac_ce_p->bsr_t = NULL; + mac_ce_p->bsr_s->LcgID = lcg_id_bsr_trunc; + mac_ce_p->bsr_s->Buffer_size = mac->scheduling_info.BSR[lcg_id_bsr_trunc]; + LOG_D(NR_MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + mac->BSR_reporting_active, + mac->scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); + } + } + + LOG_D(NR_MAC, "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", module_idP); + mac->scheduling_info.SR_pending = 0; + mac->scheduling_info.SR_COUNTER = 0; + + /* Actions when a BSR is sent */ + if (mac_ce_p->bsr_ce_len) { + LOG_D(NR_MAC, "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, mac_ce_p->bsr_ce_len, mac_ce_p->bsr_header_len, buflen); + // Reset ReTx BSR Timer + mac->scheduling_info.retxBSR_SF = nr_get_sf_retxBSRTimer(mac->scheduling_info.retxBSR_Timer); + LOG_D(NR_MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, mac->scheduling_info.retxBSR_SF); + + // Reset Periodic Timer except when BSR is truncated + if ((mac_ce_p->bsr_t == NULL) && (mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity)) { + mac->scheduling_info.periodicBSR_SF = nr_get_sf_periodicBSRTimer(mac->scheduling_info.periodicBSR_Timer); + LOG_D(NR_MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", + module_idP, + mac->scheduling_info.periodicBSR_SF); + } + + // Reset BSR Trigger flags + mac->BSR_reporting_active = BSR_TRIGGER_NONE; + } +} /** * Function: to fetch data to be transmitted from RLC, place it in the ULSCH PDU buffer to generate the complete MAC PDU with sub-headers and MAC CEs according to ULSCH MAC PDU generation (6.1.2 TS 38.321) the selected sub-header for the payload sub-PDUs is NR_MAC_SUBHEADER_LONG * @module_idP Module ID + * @CC_id Component Carrier index * @frameP current UL frame * @subframe current UL slot * @gNB_index gNB index @@ -2050,36 +2639,51 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, * @buflen TBS */ uint8_t nr_ue_get_sdu(module_id_t module_idP, + int CC_id, frame_t frameP, sub_frame_t subframe, uint8_t gNB_index, uint8_t *ulsch_buffer, uint16_t buflen) { - + NR_UE_MAC_CE_INFO mac_ce_info; + NR_UE_MAC_CE_INFO *mac_ce_p=&mac_ce_info; int16_t buflen_remain = 0; + mac_ce_p->bsr_len = 0; + mac_ce_p->bsr_ce_len = 0; + mac_ce_p->bsr_header_len = 0; + mac_ce_p->phr_len = 0; + //mac_ce_p->phr_ce_len = 0; + //mac_ce_p->phr_header_len = 0; + uint8_t lcid = 0; uint16_t sdu_length = 0; uint16_t num_sdus = 0; - uint16_t sdu_length_total = 0; + mac_ce_p->sdu_length_total = 0; + NR_BSR_SHORT bsr_short, bsr_truncated; + NR_BSR_LONG bsr_long; + mac_ce_p->bsr_s = &bsr_short; + mac_ce_p->bsr_l = &bsr_long; + mac_ce_p->bsr_t = &bsr_truncated; + //NR_POWER_HEADROOM_CMD phr; + //mac_ce_p->phr_p = &phr; NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); + //int highest_priority = 16; const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_LONG); // Pointer used to build the MAC PDU by placing the RLC SDUs in the ULSCH buffer uint8_t *pdu = ulsch_buffer; - // Preparing the MAC CEs sub-PDUs and get the total size - unsigned char mac_header_control_elements[16] = {0}; - int tot_mac_ce_len = nr_write_ce_ulsch_pdu(&mac_header_control_elements[0], mac); - uint8_t total_mac_pdu_header_len = tot_mac_ce_len; + //nr_ue_get_sdu_mac_ce_pre updates all mac_ce related header field related to length + mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(module_idP, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p); + mac_ce_p->total_mac_pdu_header_len = mac_ce_p->tot_mac_ce_len; LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] process UL transport block at with size TBS = %d bytes \n", __FUNCTION__, module_idP, frameP, subframe, buflen); // Check for DCCH first // TO DO: Multiplex in the order defined by the logical channel prioritization - for (lcid = UL_SCH_LCID_SRB1; - lcid < MAX_LCID; lcid++) { + for (lcid = UL_SCH_LCID_SRB1; lcid < MAX_LCID; lcid++) { - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + sh_size); + buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size); LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header len %d bytes, buflen_remain %d bytes)\n", __FUNCTION__, @@ -2088,8 +2692,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, subframe, lcid, buflen, - sdu_length_total, - tot_mac_ce_len, + mac_ce_p->sdu_length_total, + mac_ce_p->tot_mac_ce_len, buflen_remain); while (buflen_remain > 0){ @@ -2119,7 +2723,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, if (sdu_length > 0) { - LOG_D(MAC, "In %s: Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID 0x%02x (buflen (TBS) %d bytes)\n", __FUNCTION__, + LOG_D(NR_MAC, "In %s: Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID 0x%02x (buflen (TBS) %d bytes)\n", __FUNCTION__, num_sdus + 1, sdu_length, lcid, @@ -2139,40 +2743,53 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, #endif pdu += sdu_length; - sdu_length_total += sdu_length; - total_mac_pdu_header_len += sh_size; + mac_ce_p->sdu_length_total += sdu_length; + mac_ce_p->total_mac_pdu_header_len += sh_size; num_sdus++; } else { pdu -= sh_size; - LOG_D(MAC, "In %s: no data to transmit for RB with LCID 0x%02x\n", __FUNCTION__, lcid); + LOG_D(NR_MAC, "In %s: no data to transmit for RB with LCID 0x%02x\n", __FUNCTION__, lcid); break; } - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + sh_size); + buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size); + //Update Buffer remain and BSR bytes after transmission + mac->scheduling_info.LCID_buffer_remain[lcid] -= sdu_length; + mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]] -= sdu_length; + LOG_D(NR_MAC, "[UE %d] Update BSR [%d.%d] BSR_bytes for LCG%d=%d\n", + module_idP, frameP, subframe, mac->scheduling_info.LCGID[lcid], + mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]]); + if (mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]] < 0) + mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]] = 0; } } - if (tot_mac_ce_len > 0) { + //nr_ue_get_sdu_mac_ce_post recalculates all mac_ce related header fields since buffer has been changed after mac_rlc_data_req. + //Also, BSR padding is handled here after knowing mac_ce_p->sdu_length_total. + nr_ue_get_sdu_mac_ce_post(module_idP, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p); - LOG_D(NR_MAC, "In %s copying %d bytes of MAC CEs to the UL PDU \n", __FUNCTION__, tot_mac_ce_len); - memcpy((void *) pdu, (void *) mac_header_control_elements, tot_mac_ce_len); - pdu += (unsigned char) tot_mac_ce_len; + if (mac_ce_p->tot_mac_ce_len > 0) { + + LOG_D(NR_MAC, "In %s copying %d bytes of MAC CEs to the UL PDU \n", __FUNCTION__, mac_ce_p->tot_mac_ce_len); + nr_write_ce_ulsch_pdu(pdu, mac, 0, NULL, mac_ce_p->bsr_t, mac_ce_p->bsr_s, mac_ce_p->bsr_l); + pdu += (unsigned char) mac_ce_p->tot_mac_ce_len; #ifdef ENABLE_MAC_PAYLOAD_DEBUG - LOG_I(NR_MAC, "In %s: dumping MAC CE with length tot_mac_ce_len %d: \n", __FUNCTION__, tot_mac_ce_len); - log_dump(NR_MAC, mac_header_control_elements, tot_mac_ce_len, LOG_DUMP_CHAR, "\n"); + LOG_I(NR_MAC, "In %s: dumping MAC CE with length tot_mac_ce_len %d: \n", __FUNCTION__, mac_ce_p->tot_mac_ce_len); + log_dump(NR_MAC, mac_header_control_elements, mac_ce_p->tot_mac_ce_len, LOG_DUMP_CHAR, "\n"); #endif } - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total); + buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total); // Compute final offset for padding and fill remainder of ULSCH with 0 if (buflen_remain > 0) { + LOG_D(NR_MAC, "In %s filling remainder %d bytes to the UL PDU \n", __FUNCTION__, buflen_remain); ((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 13a2cb48dd..cedd095794 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -33,7 +33,7 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" #include "common/ran_context.h" - +#include "common/utils/nr/nr_common.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -318,7 +318,16 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts scs_scaling = scs_scaling>>2; uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); uint16_t sco = absolute_diff%(12*scs_scaling); - AssertFatal(sco==0,"absoluteFrequencySSB has a subcarrier offset of %d while it should be alligned with CRBs\n",sco); + // values of subcarrier offset larger than the limit only indicates CORESET for Type0-PDCCH CSS set is not present + uint8_t ssb_SubcarrierOffset_limit = 0; + if(frequency_range == FR1) { + ssb_SubcarrierOffset_limit = 24; + } else { + ssb_SubcarrierOffset_limit = 12; + } + if (ssb_SubcarrierOffsetssb_table.ssb_offset_point_a.value = absolute_diff/(12*scs_scaling) - 10; //absoluteFrequencySSB is the central frequency of SSB which is made by 20RBs in total cfg->ssb_table.ssb_offset_point_a.tl.tag = NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG; cfg->num_tlv++; @@ -421,9 +430,10 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, int pusch_AntennaPorts, int sib1_tda, NR_ServingCellConfigCommon_t *scc, - int add_ue, + NR_BCCH_BCH_Message_t *mib, + int add_ue, uint32_t rnti, - NR_CellGroupConfig_t *CellGroup) { + NR_CellGroupConfig_t *CellGroup) { if (scc != NULL ) { AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present); @@ -458,7 +468,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, ssb_SubcarrierOffset, pdsch_AntennaPorts, pusch_AntennaPorts, - scc); + scc); LOG_D(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); // if in nFAPI mode @@ -519,7 +529,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, } } } - + + if (mib) RC.nrmac[Mod_idP]->common_channels[0].mib = mib; + if (CellGroup) { const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; @@ -531,11 +543,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, const NR_BWP_Downlink_t *bwp = bwpList->list.array[i]; calculate_preferred_dl_tda(Mod_idP, bwp); } + } else { + calculate_preferred_dl_tda(Mod_idP, NULL); } const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; if(ubwpList) { - AssertFatal(ubwpList->list.count > 0, "downlinkBWP_ToAddModList no BWPs!\n"); + AssertFatal(ubwpList->list.count > 0, "uplinkBWP_ToAddModList no BWPs!\n"); for (int i = 0; i < ubwpList->list.count; ++i) { const NR_BWP_Uplink_t *ubwp = ubwpList->list.array[i]; calculate_preferred_ul_tda(Mod_idP, ubwp); @@ -592,9 +606,26 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti); } else { // CellGroup has been updated const int UE_id = find_nr_UE_id(Mod_idP,rnti); + int target_ss; UE_info->CellGroup[UE_id] = CellGroup; LOG_I(NR_MAC,"Modified UE_id %d/%x with CellGroup\n",UE_id,rnti); process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); + // update coreset/searchspace + void *bwpd = NULL; + target_ss = NR_SearchSpace__searchSpaceType_PR_common; + if ((UE_info->UE_sched_ctrl[UE_id].active_bwp)) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + bwpd = (void*)UE_info->UE_sched_ctrl[UE_id].active_bwp->bwp_Dedicated; + } + else if (CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + (CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + bwpd = (void*)CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + } + UE_info->UE_sched_ctrl[UE_id].search_space = get_searchspace(scc, bwpd, target_ss); + UE_info->UE_sched_ctrl[UE_id].coreset = get_coreset(Mod_idP, scc, bwpd, UE_info->UE_sched_ctrl[UE_id].search_space, target_ss); + UE_info->UE_sched_ctrl[UE_id].maxL = 2; } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 252144be3b..b62f8e0282 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -46,9 +46,6 @@ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "openair1/PHY/defs_gNB.h" -#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" - #include "intertask_interface.h" #include "executables/softmodem-common.h" @@ -62,80 +59,6 @@ uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; uint8_t vnf_first_sched_entry = 1; -void clear_mac_stats(gNB_MAC_INST *gNB) { - memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); -} -#define MACSTATSSTRLEN 16384 -void dump_mac_stats(gNB_MAC_INST *gNB) -{ - NR_UE_info_t *UE_info = &gNB->UE_info; - int num = 1; - FILE *fd=fopen("nrMAC_stats.log","w"); - AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); - char output[MACSTATSSTRLEN]; - memset(output,0,MACSTATSSTRLEN); - int stroff=0; - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - stroff = sprintf(output,"UE ID %d RNTI %04x (%d/%d)\n", UE_id, UE_info->rnti[UE_id], num++, UE_info->num_UEs); - LOG_I(NR_MAC, "UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm\n", - UE_id, - UE_info->rnti[UE_id], - num++, - UE_info->num_UEs, - UE_info->UE_sched_ctrl[UE_id].ph, - UE_info->UE_sched_ctrl[UE_id].pcmax); - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; - const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; - stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, average RSRP %d (%d meas)\n", - UE_id, - stats->dlsch_rounds[0], stats->dlsch_rounds[1], - stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, - avg_rsrp, stats->num_rsrp_meas); - LOG_I(NR_MAC, "UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, average RSRP %d (%d meas)\n", - UE_id, - stats->dlsch_rounds[0], stats->dlsch_rounds[1], - stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, - avg_rsrp, stats->num_rsrp_meas); - stats->num_rsrp_meas = 0; - stats->cumul_rsrp = 0 ; - stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); - stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", - UE_id, - stats->ulsch_rounds[0], stats->ulsch_rounds[1], - stats->ulsch_rounds[2], stats->ulsch_rounds[3], - stats->ulsch_DTX, - stats->ulsch_errors); - stroff+=sprintf(output+stroff, - "UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n", - UE_id, - stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); - LOG_I(NR_MAC, "UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); - LOG_I(NR_MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", - UE_id, - stats->ulsch_rounds[0], stats->ulsch_rounds[1], - stats->ulsch_rounds[2], stats->ulsch_rounds[3], - stats->ulsch_DTX, - stats->ulsch_errors); - LOG_I(NR_MAC, - "UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n", - UE_id, - stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); - for (int lc_id = 0; lc_id < 63; lc_id++) { - if (stats->lc_bytes_tx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); - } - if (stats->lc_bytes_rx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); - } - } - } - print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL); - if (stroff>0) fprintf(fd,"%s",output); - fclose(fd); -} - void clear_nr_nfapi_information(gNB_MAC_INST * gNB, int CC_idP, frame_t frameP, @@ -354,6 +277,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); const int bwp_id = 1; + char stats_output[16384]; gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = gNB->common_channels; @@ -384,6 +308,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } memset(RC.nrmac[module_idP]->cce_list[0][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0 + memset(RC.nrmac[module_idP]->cce_list[0][1],0,MAX_NUM_CCE*sizeof(int)); // coreset1 on initialBWP memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1 NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) @@ -420,8 +345,11 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } - if ((slot == 0) && (frame & 127) == 0) dump_mac_stats(RC.nrmac[module_idP]); - + if ((slot == 0) && (frame & 127) == 0) { + stats_output[0]='\0'; + dump_mac_stats(RC.nrmac[module_idP],stats_output,16384); + LOG_I(NR_MAC,"Frame.Slot %d.%d\n%s\n",frame,slot,stats_output); + } // This schedules MIB schedule_nr_mib(module_idP, frame, slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 26ef47f152..af3fff6d79 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -261,6 +261,8 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP else mu = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int bwp_start = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + uint8_t fdm = cfg->prach_config.num_prach_fd_occasions.value; // prach is scheduled according to configuration index and tables 6.3.3.2.2 to 6.3.3.2.4 if ( get_nr_prach_info_from_index(config_index, @@ -387,7 +389,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP const int16_t N_RA_RB = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); uint16_t *vrb_map_UL = &cc->vrb_map_UL[slotP * MAX_BWP_SIZE]; for (int i = 0; i < N_RA_RB * fdm; ++i) - vrb_map_UL[rach_ConfigGeneric->msg1_FrequencyStart + i] = 0xff; // all symbols + vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = 0xff; // all symbols } } } @@ -691,20 +693,22 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1] : - NULL; - - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList= ubwp ? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - - int mu = ubwp ? - ubwp->bwp_Common->genericParameters.subcarrierSpacing : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + NR_BWP_Uplink_t *ubwp = NULL; + NR_BWP_UplinkDedicated_t *ubwpd = NULL; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + NR_BWP_t *genericParameters = NULL; + if(ra->CellGroup) { + ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + genericParameters = &ubwp->bwp_Common->genericParameters; + pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } else { + genericParameters = &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + int mu = genericParameters->subcarrierSpacing; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; - const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -722,36 +726,23 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t tdd_beam_association[num_tdd_period] = ra->beam_id; } - int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - if (ra->CellGroup) { - AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; - fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; - if ((bwpStart < act_bwp_start) || (bwpSize > act_bwp_size)) - bwpStart = act_bwp_start; - } - uint16_t *vrb_map_UL = - &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; + uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; + int BWPStart = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].cset_start_rb; + int BWPSize = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].num_rbs; int rbStart = 0; - for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (bwpSize - ra->msg3_nb_rb)); i++) { - if (vrb_map_UL[rbStart + bwpStart + i]) { + for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) { + if (vrb_map_UL[rbStart + BWPStart + i]) { rbStart += i; i = 0; } } - if (rbStart > (bwpSize - ra->msg3_nb_rb)) { + if (rbStart > (BWPSize - ra->msg3_nb_rb)) { // cannot find free vrb_map for msg3 retransmission in this slot return; } @@ -776,33 +767,14 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->msg3_round, startSymbolAndLength, ra->rnti, scs, - bwpSize, bwpStart, + BWPSize, BWPStart, mappingtype, fh, rbStart, ra->msg3_nb_rb); future_ul_tti_req->n_pdus += 1; // generation of DCI 0_0 to schedule msg3 retransmission NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = NULL; - NR_ControlResourceSet_t *coreset = NULL; - - NR_BWP_t *genericParameters = NULL; - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; - genericParameters = &bwp->bwp_Common->genericParameters; - } - else { - genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - - if (*ss->controlResourceSetId == 0) - coreset = nr_mac->sched_ctrlCommon->coreset; // this is coreset 0 - else - coreset = get_coreset(scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + NR_ControlResourceSet_t *coreset = get_coreset(module_idP, scc, NULL, ss, NR_SearchSpace__searchSpaceType_PR_common); AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg3 retransmission\n"); nfapi_nr_ul_dci_request_t *ul_dci_req = &nr_mac->UL_dci_req[CC_id]; @@ -816,14 +788,19 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); + nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid] = pdcch_pdu_rel15; } uint8_t aggregation_level; uint8_t nr_of_candidates; - find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); - int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level, 0, 0, nr_of_candidates); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss, 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); + int CCEIndex = allocate_nr_CCEs(nr_mac, NULL, coreset, aggregation_level, 0, 0, nr_of_candidates); if (CCEIndex < 0) { LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); return; @@ -844,6 +821,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t memset(&uldci_payload, 0, sizeof(uldci_payload)); config_uldci(ubwp, + ubwpd, scc, pusch_pdu, &uldci_payload, @@ -864,7 +842,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t // Mark the corresponding RBs as used for (int rb = 0; rb < ra->msg3_nb_rb; rb++) { - vrb_map_UL[rbStart + bwpStart + rb] = 1; + vrb_map_UL[rbStart + BWPStart + rb] = 1; } // reset state to wait msg3 @@ -887,7 +865,7 @@ void nr_get_Msg3alloc(module_id_t module_id, // msg3 is scheduled in mixed slot in the following TDD period - uint16_t msg3_nb_rb = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // sdu has 6 or 8 bytes + uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : @@ -940,10 +918,19 @@ void nr_get_Msg3alloc(module_id_t module_id, LOG_D(NR_MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u start symbol index %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id, StartSymbolIndex); uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = NRRIV2BW(ubwp ? - ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + + int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + if (ra->CellGroup) { + AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; + int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) + bwpStart = act_bwp_start; + } /* search msg3_nb_rb free RBs */ int rbSize = 0; @@ -951,16 +938,17 @@ void nr_get_Msg3alloc(module_id_t module_id, while (rbSize < msg3_nb_rb) { rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; - while (rbStart < bwpSize && vrb_map_UL[rbStart]) + while (rbStart < bwpSize && vrb_map_UL[rbStart + bwpStart]) rbStart++; AssertFatal(rbStart < bwpSize - msg3_nb_rb, "no space to allocate Msg 3 for RA!\n"); while (rbStart + rbSize < bwpSize - && !vrb_map_UL[rbStart + rbSize] + && !vrb_map_UL[rbStart + bwpStart + rbSize] && rbSize < msg3_nb_rb) rbSize++; } ra->msg3_nb_rb = msg3_nb_rb; ra->msg3_first_rb = rbStart; + ra->msg3_bwp_start = bwpStart; } @@ -1046,12 +1034,12 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; for (int i = 0; i < ra->msg3_nb_rb; ++i) { - AssertFatal(!vrb_map_UL[i + ra->msg3_first_rb], + AssertFatal(!vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start], "RB %d in %4d.%2d is already taken, cannot allocate Msg3!\n", i + ra->msg3_first_rb, ra->Msg3_frame, ra->Msg3_slot); - vrb_map_UL[i + ra->msg3_first_rb] = 1; + vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] = 1; } LOG_D(NR_MAC, "[gNB %d][RAPROC] Frame %d, Slot %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); @@ -1070,9 +1058,6 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int ibwp_start = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int abwp_size = ibwp_size; - int abwp_start = ibwp_start; int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; @@ -1085,8 +1070,6 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; } @@ -1101,17 +1084,11 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t ra->msg3_round, ra->rnti); - int bwp_start; - if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) - bwp_start = abwp_start; - else - bwp_start = ibwp_start; - fill_msg3_pusch_pdu(pusch_pdu,scc, ra->msg3_round, startSymbolAndLength, ra->rnti, scs, - ibwp_size, bwp_start, + ibwp_size, ra->msg3_bwp_start, mappingtype, fh, ra->msg3_first_rb, ra->msg3_nb_rb); future_ul_tti_req->n_pdus += 1; @@ -1136,13 +1113,10 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - long BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - NR_BWP_Downlink_t *bwp = NULL; NR_ControlResourceSet_t *coreset = NULL; NR_BWP_t *genericParameters = NULL; NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - long BWPStart = 0; if (ra->CellGroup && ra->CellGroup->spCellConfig && @@ -1157,18 +1131,26 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } - BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - if (*ss->controlResourceSetId == 0) - coreset = nr_mac->sched_ctrlCommon->coreset; // this is coreset 0 - else - coreset = get_coreset(scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + long BWPStart = 0; + long BWPSize = 0; + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; + if(*ss->controlResourceSetId!=0) { + BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else { + type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; + BWPStart = type0_PDCCH_CSS_config->cset_start_rb; + BWPSize = type0_PDCCH_CSS_config->num_rbs; + } + + coreset = get_coreset(module_idP, scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); uint16_t *vrb_map = cc[CC_id].vrb_map; for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) { - if (vrb_map[rbStart + i]) { + if (vrb_map[BWPStart + rbStart + i]) { rbStart += i; i = 0; } @@ -1188,7 +1170,12 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint8_t aggregation_level; uint8_t nr_of_candidates; - find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss, 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates); if (CCEIndex < 0) { LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); @@ -1201,7 +1188,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); - LOG_D(MAC,"Msg2 startSymbolIndex.nrOfSymbols %d.%d\n",startSymbolIndex,nrOfSymbols); + LOG_D(NR_MAC,"Msg2 startSymbolIndex.nrOfSymbols %d.%d\n",startSymbolIndex,nrOfSymbols); int mappingtype = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->mappingType; @@ -1217,7 +1204,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); + nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; } @@ -1228,8 +1215,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs+=1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - LOG_I(NR_MAC,"[gNB %d][RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg2 DCI, rnti 0x%x, state %d\n", - module_idP, CC_id, frameP, slotP, ra->RA_rnti, ra->state); + LOG_I(NR_MAC,"[gNB %d][RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg2 DCI, rnti 0x%x, state %d, CoreSetType %d\n", + module_idP, CC_id, frameP, slotP, ra->RA_rnti, ra->state,pdcch_pdu_rel15->CoreSetType); // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control // information to data and is reset every slot. @@ -1310,7 +1297,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_pdu_rel15_t dci_payload; dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->BWPSize); + BWPSize); + + LOG_D(NR_MAC,"Msg2 rbSize.rbStart.BWPsize %d.%d.%ld\n",pdsch_pdu_rel15->rbSize, + pdsch_pdu_rel15->rbStart, + BWPSize); dci_payload.time_domain_assignment.val = time_domain_assignment; dci_payload.vrb_to_prb_mapping.val = 0; @@ -1318,11 +1309,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.tb_scaling = tb_scaling; LOG_D(NR_MAC, - "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d \n", + "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%ld), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d \n", dci_payload.frequency_domain_assignment.val, pdsch_pdu_rel15->rbStart, pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->BWPSize, + BWPSize, dci_payload.time_domain_assignment.val, dci_payload.vrb_to_prb_mapping.val, dci_payload.mcs, @@ -1333,7 +1324,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdcch_pdu_rel15->dci_pdu[0].RNTI, NR_RNTI_RA, NR_DL_DCI_FORMAT_1_0, - (unsigned long long)pdcch_pdu_rel15->FreqDomainResource, + *(unsigned long long *)pdcch_pdu_rel15->FreqDomainResource, pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->DurationSymbols); @@ -1343,7 +1334,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, - pdsch_pdu_rel15->BWPSize, + BWPSize, bwpid); // DL TX request @@ -1373,11 +1364,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Mark the corresponding RBs as used for (int rb = 0; rb < rbSize; rb++) { - vrb_map[rb + rbStart] = 1; + vrb_map[BWPStart + rb + rbStart] = 1; } ra->state = WAIT_Msg3; - LOG_I(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); } } @@ -1401,7 +1392,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_BWP_Downlink_t *bwp = NULL; NR_ControlResourceSet_t *coreset = NULL; - NR_BWP_t *genericParameters = NULL; NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; if (ra->CellGroup && @@ -1410,18 +1400,13 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; - genericParameters = &bwp->bwp_Common->genericParameters; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { - genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } - if (*ss->controlResourceSetId == 0) - coreset = nr_mac->sched_ctrlCommon->coreset; // this is coreset 0 - else - coreset = get_coreset(scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + coreset = get_coreset(module_idP, scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); @@ -1429,8 +1414,19 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - long BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - long BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + + long BWPStart = 0; + long BWPSize = 0; + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; + if(*ss->controlResourceSetId!=0) { + BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else { + type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; + BWPStart = type0_PDCCH_CSS_config->cset_start_rb; + BWPSize = type0_PDCCH_CSS_config->num_rbs; + } /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ int current_harq_pid = sched_ctrl->retrans_dl_harq.head; @@ -1450,7 +1446,12 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // get CCEindex, needed also for PUCCH and then later for PDCCH uint8_t aggregation_level; uint8_t nr_of_candidates; - find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss, 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates); if (CCEIndex < 0) { LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); @@ -1467,8 +1468,9 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra const int delta_PRI=0; int r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); - int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch); - AssertFatal(alloc>=0,"%d.%d Couldn't find a pucch allocation for ack nack (msg4), r_pucch %d (CCEindex%d,N_cce%d\n",frameP,slotP,r_pucch,CCEIndex,N_cce); + LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, N_cce %d, nb_of_candidates %d,delta_PRI %d)\n",r_pucch,CCEIndex,N_cce,nr_of_candidates,delta_PRI); + int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch, 1); + AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; harq->feedback_slot = pucch->ul_slot; harq->feedback_frame = pucch->frame; @@ -1550,7 +1552,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int i = 0; while ((i < rbSize) && (rbStart + rbSize <= BWPSize)) { - if (vrb_map[rbStart + i]) { + if (vrb_map[BWPStart + rbStart + i]) { rbStart += i+1; i = 0; } else { @@ -1583,7 +1585,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); + nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; } @@ -1653,7 +1655,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_pdu_rel15_t dci_payload; dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->BWPSize); + BWPSize); dci_payload.format_indicator = 1; dci_payload.time_domain_assignment.val = time_domain_assignment; @@ -1669,7 +1671,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.pdsch_to_harq_feedback_timing_indicator.val = pucch->timing_indicator; LOG_D(NR_MAC, - "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d pucchres %d harqtiming %d\n", + "[RAPROC] DCI 1_0 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d pucchres %d harqtiming %d\n", dci_payload.frequency_domain_assignment.val, pdsch_pdu_rel15->rbStart, pdsch_pdu_rel15->rbSize, @@ -1682,13 +1684,14 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.pdsch_to_harq_feedback_timing_indicator.val); LOG_D(NR_MAC, - "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", + "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d, BWPsize %d\n", pdcch_pdu_rel15->dci_pdu[0].RNTI, NR_RNTI_TC, NR_DL_DCI_FORMAT_1_0, (unsigned long long)pdcch_pdu_rel15->FreqDomainResource, pdcch_pdu_rel15->StartSymbolIndex, - pdcch_pdu_rel15->DurationSymbols); + pdcch_pdu_rel15->DurationSymbols, + pdsch_pdu_rel15->BWPSize); fill_dci_pdu_rel15(scc, ra->CellGroup, @@ -1725,7 +1728,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Mark the corresponding RBs as used for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) { - vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1; + vrb_map[BWPStart + rb + pdsch_pdu_rel15->rbStart] = 1; } LOG_D(NR_MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); @@ -1744,7 +1747,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_D(NR_MAC,"numDlDci: %i\n", pdcch_pdu_rel15->numDlDci); ra->state = WAIT_Msg4_ACK; - LOG_I(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); } } @@ -1934,7 +1937,7 @@ void nr_fill_rar(uint8_t Mod_idP, // TC-RNTI int t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); - LOG_I(NR_MAC, "In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n", + LOG_D(NR_MAC, "In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n", __FUNCTION__, Msg3_t_alloc, Msg3_f_alloc, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index b74432b2ae..f35de9e28b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -219,6 +219,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) ssb_start_symbol, scs, FR1, + band, i_ssb, ssb_frame_periodicity, offset_pointa); @@ -246,6 +247,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) ssb_start_symbol, scs, FR1, + band, i_ssb, ssb_frame_periodicity, offset_pointa); @@ -281,6 +283,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) ssb_start_symbol, scs, FR2, + band, i_ssb, ssb_frame_periodicity, offset_pointa); @@ -328,19 +331,16 @@ uint32_t schedule_control_sib1(module_id_t module_id, gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; - int ret; if (gNB_mac->sched_ctrlCommon == NULL){ LOG_D(NR_MAC,"schedule_control_common: Filling nr_mac->sched_ctrlCommon\n"); gNB_mac->sched_ctrlCommon = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon)); gNB_mac->sched_ctrlCommon->search_space = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->search_space)); gNB_mac->sched_ctrlCommon->coreset = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->coreset)); - for (int i=0; i<3; i++){ // loop over possible aggregation levels - ret = fill_searchSpaceZero(gNB_mac->sched_ctrlCommon->search_space,type0_PDCCH_CSS_config,4<sched_ctrlCommon->search_space,type0_PDCCH_CSS_config); fill_coresetZero(gNB_mac->sched_ctrlCommon->coreset,type0_PDCCH_CSS_config); + gNB_mac->cset0_bwp_start = type0_PDCCH_CSS_config->cset_start_rb; + gNB_mac->cset0_bwp_size = type0_PDCCH_CSS_config->num_rbs; } gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation = time_domain_allocation; @@ -349,8 +349,12 @@ uint32_t schedule_control_sib1(module_id_t module_id, gNB_mac->sched_ctrlCommon->num_total_bytes = num_total_bytes; uint8_t nr_of_candidates; - find_aggregation_candidates(&gNB_mac->sched_ctrlCommon->aggregation_level, &nr_of_candidates, gNB_mac->sched_ctrlCommon->search_space); + for (int i=0; i<3; i++) { + find_aggregation_candidates(&gNB_mac->sched_ctrlCommon->aggregation_level, &nr_of_candidates, gNB_mac->sched_ctrlCommon->search_space,4<0) break; // choosing the lower value of aggregation level available + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); gNB_mac->sched_ctrlCommon->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], NULL, gNB_mac->sched_ctrlCommon->coreset, @@ -434,7 +438,8 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, + nr_configure_pdcch(NULL, + pdcch_pdu_rel15, gNB_mac->sched_ctrlCommon->search_space, gNB_mac->sched_ctrlCommon->coreset, scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 9e9e105ba0..c40a665d4a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -29,11 +29,7 @@ */ -/*PHY*/ -#include "PHY/CODING/coding_defs.h" -#include "PHY/defs_nr_common.h" #include "common/utils/nr/nr_common.h" -#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" /*MAC*/ #include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_gNB/nr_mac_gNB.h" @@ -56,7 +52,6 @@ #define HALFWORD 16 #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) -static int loop_dcch_dtch = DL_SCH_LCID_DTCH; void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) { @@ -71,16 +66,22 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t * scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int symb_dlMixed = tdd ? (1 << tdd->nrofDownlinkSymbols) - 1 : 0; - const int target_ss = bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; + int target_ss; + if (bwp) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + } + else { + target_ss = NR_SearchSpace__searchSpaceType_PR_common; + } NR_SearchSpace_t *search_space = get_searchspace(scc, bwp ? bwp->bwp_Dedicated : NULL, target_ss); - const NR_ControlResourceSet_t *coreset = get_coreset(scc, (NR_BWP_Downlink_t*)bwp, search_space, target_ss); - + NR_ControlResourceSet_t *coreset = get_coreset(module_id, scc, bwp ? bwp->bwp_Dedicated : NULL, search_space, target_ss); // get coreset symbol "map" const uint16_t symb_coreset = (1 << coreset->duration) - 1; /* check that TDA index 0 fits into DL and does not overlap CORESET */ - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = bwp ? + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : + scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; AssertFatal(tdaList->list.count >= 1, "need to have at least one TDA for DL slots\n"); const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_DL = tdaList->list.array[0]; AssertFatal(!tdaP_DL->k0 || *tdaP_DL->k0 == 0, @@ -131,7 +132,7 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t * nrmac->preferred_dl_tda[bwp_id][i] = 0; else if (tdd && nr_mix_slots && i % nr_slots_period == tdd->nrofDownlinkSlots) nrmac->preferred_dl_tda[bwp_id][i] = tdaMi; - LOG_I(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]); + LOG_D(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]); } } @@ -391,39 +392,57 @@ void nr_store_dlsch_buffer(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; sched_ctrl->num_total_bytes = 0; - if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH1) - loop_dcch_dtch = DL_SCH_LCID_DTCH; - else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DTCH) - loop_dcch_dtch = DL_SCH_LCID_DCCH; - /*else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH) - loop_dcch_dtch = DL_SCH_LCID_DCCH1;*/ - else if ((sched_ctrl->lcid_mask&(1<<2)) > 0){ //&& loop_dcch_dtch == DL_SCH_LCID_DCCH - if (loop_dcch_dtch == DL_SCH_LCID_DCCH) - loop_dcch_dtch = DL_SCH_LCID_DCCH1; - else if(loop_dcch_dtch == DL_SCH_LCID_DCCH1) - loop_dcch_dtch = DL_SCH_LCID_DCCH; - } - const int lcid = loop_dcch_dtch; - // const int lcid = DL_SCH_LCID_DTCH; + int lcid; const uint16_t rnti = UE_info->rnti[UE_id]; - sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, - rnti, - module_id, - frame, - slot, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - 0, - 0); + LOG_D(NR_MAC,"UE %d/%x : lcid_mask %x\n",UE_id,rnti,sched_ctrl->lcid_mask); + if ((sched_ctrl->lcid_mask&(1<<2)) > 0) + sched_ctrl->rlc_status[DL_SCH_LCID_DCCH1] = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DL_SCH_LCID_DCCH1, + 0, + 0); + if ((sched_ctrl->lcid_mask&(1<<1)) > 0) + sched_ctrl->rlc_status[DL_SCH_LCID_DCCH] = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DL_SCH_LCID_DCCH, + 0, + 0); + if ((sched_ctrl->lcid_mask&(1<<4)) > 0) + sched_ctrl->rlc_status[DL_SCH_LCID_DTCH] = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DL_SCH_LCID_DTCH, + 0, + 0); + + if(sched_ctrl->rlc_status[DL_SCH_LCID_DCCH].bytes_in_buffer > 0){ + lcid = DL_SCH_LCID_DCCH; + } + else if (sched_ctrl->rlc_status[DL_SCH_LCID_DCCH1].bytes_in_buffer > 0) + { + lcid = DL_SCH_LCID_DCCH1; + }else{ + lcid = DL_SCH_LCID_DTCH; + } + sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; - LOG_D(NR_MAC, - "%d.%d, LCID%d:->DLSCH, RLC status %d bytes. \n", - frame, - slot, - lcid, - sched_ctrl->num_total_bytes); + //later multiplex here. Just select DCCH/SRB before DTCH/DRB + sched_ctrl->lcid_to_schedule = lcid; if (sched_ctrl->num_total_bytes == 0 && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ @@ -453,17 +472,22 @@ bool allocate_dl_retransmission(module_id_t module_id, NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; + + NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? &sched_ctrl->active_bwp->bwp_Common->genericParameters : &RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - int rbStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; + const long f = (sched_ctrl->active_bwp ||bwpd) ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; int rbSize = 0; - const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); if (tda == retInfo->time_domain_allocation) { /* Check that there are enough resources for retransmission */ while (rbSize < retInfo->rbSize) { @@ -481,7 +505,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ if (ps->time_domain_allocation != tda) - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, f, ps); + nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, f, ps); } else { /* the retransmission will use a different time domain allocation, check * that we have enough resources */ @@ -491,7 +515,7 @@ bool allocate_dl_retransmission(module_id_t module_id, rbSize++; NR_pdsch_semi_static_t temp_ps; temp_ps.nrOfLayers = 1; - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, f, &temp_ps); + nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, f, &temp_ps); uint32_t new_tbs; uint16_t new_rbSize; bool success = nr_find_nb_rb(retInfo->Qm, @@ -524,7 +548,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); if (alloc<0) { LOG_D(MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", @@ -535,18 +559,18 @@ bool allocate_dl_retransmission(module_id_t module_id, slot); int cid = sched_ctrl->coreset->controlResourceSetId; UE_info->num_pdcch_cand[UE_id][cid]--; - int *cce_list = RC.nrmac[module_id]->cce_list[sched_ctrl->active_bwp->bwp_Id][cid]; + int *cce_list = RC.nrmac[module_id]->cce_list[sched_ctrl->active_bwp?sched_ctrl->active_bwp->bwp_Id:0][cid]; for (int i = 0; i < sched_ctrl->aggregation_level; i++) cce_list[sched_ctrl->cce_index + i] = 0; return false; } - sched_ctrl->sched_pdsch.pucch_allocation = alloc; - /* just reuse from previous scheduling opportunity, set new start RB */ sched_ctrl->sched_pdsch = *retInfo; sched_ctrl->sched_pdsch.rbStart = rbStart; + sched_ctrl->sched_pdsch.pucch_allocation = alloc; + /* retransmissions: directly allocate */ *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize; for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++) @@ -636,6 +660,8 @@ void pf_dl(module_id_t module_id, p = &UE_sched.next[*max]; *max = UE_sched.next[*max]; *p = -1; + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; int bwp_Id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; @@ -645,7 +671,7 @@ void pf_dl(module_id_t module_id, &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - int rbStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = 0; // start wrt BWPstart /* Find a free CCE */ bool freeCCE = find_free_CCE(module_id, slot, UE_id); @@ -659,7 +685,7 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1,0); if (alloc<0) { LOG_D(NR_MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", @@ -684,12 +710,14 @@ void pf_dl(module_id_t module_id, max_rbSize++; /* MCS has been set above */ - const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + + const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; + const long f = (sched_ctrl->active_bwp || bwpd) ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; if (ps->time_domain_allocation != tda) - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, f, ps); + nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, f, ps); sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->pucch_allocation = alloc; @@ -718,14 +746,12 @@ void pf_dl(module_id_t module_id, void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - if (UE_info->num_UEs == 0) return; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const int CC_id = 0; - /* Get bwpSize from the first UE */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; @@ -734,6 +760,10 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp ? + sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, + MAX_BWP_SIZE); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; uint8_t rballoc_mask[bwpSize]; @@ -741,7 +771,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t for (int i = 0; i < bwpSize; i++) { // calculate mask: init with "NOT" vrb_map: // if any RB in vrb_map is blocked (1), the current RBG will be 0 - rballoc_mask[i] = !vrb_map[i]; + rballoc_mask[i] = !vrb_map[i+BWPStart]; n_rb_sched += rballoc_mask[i]; } @@ -812,6 +842,8 @@ void nr_schedule_ue_spec(module_id_t module_id, if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; UE_info->mac_stats[UE_id].dlsch_current_bytes = 0; + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; /* update TA and set ta_apply every 10 frames. * Possible improvement: take the periodicity from input file. @@ -866,19 +898,28 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; LOG_D(NR_MAC, - "%4d.%2d RNTI %04x start %3d RBs %3d startSymbol %2d nb_symbol %2d MCS %2d TBS %4d HARQ PID %2d round %d NDI %d\n", + "%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", frame, slot, + UE_id, rnti, + sched_ctrl->aggregation_level, sched_pdsch->rbStart, sched_pdsch->rbSize, ps->startSymbolIndex, ps->nrOfSymbols, + ps->dl_dmrs_symb_pos, sched_pdsch->mcs, TBS, current_harq_pid, harq->round, - harq->ndi); + nr_rv_round_map[harq->round], + harq->ndi, + pucch->timing_indicator, + pucch->frame, + pucch->ul_slot, + sched_pdsch->pucch_allocation, + sched_ctrl->tpc1); NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; @@ -889,7 +930,7 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_BWP_t *genericParameters = bwp ? &bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; const int bwpid = bwp ? bwp->bwp_Id : 0; - const int coresetid = bwp ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; + const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; if (!pdcch_pdu) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -898,10 +939,10 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - LOG_D(NR_MAC,"Trying to configure DL pdcch for bwp %d, cs %d\n",bwpid,coresetid); - NR_SearchSpace_t *ss = bwp ? sched_ctrl->search_space:gNB_mac->sched_ctrlCommon->search_space; - NR_ControlResourceSet_t *coreset = bwp? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; - nr_configure_pdcch(pdcch_pdu, ss, coreset, scc, genericParameters, NULL); + LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %d, bwp %d, cs %d\n",UE_id,bwpid,coresetid); + NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space:gNB_mac->sched_ctrlCommon->search_space; + NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; + nr_configure_pdcch(gNB_mac, pdcch_pdu, ss, coreset, scc, genericParameters, NULL); gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu; } @@ -1034,7 +1075,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.dmrs_sequence_initialization.val = pdsch_pdu->SCID; LOG_D(NR_MAC, "%4d.%2d DCI type 1 payload: freq_alloc %d (%d,%d,%d), " - "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d tpc %d\n", + "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d tpc %d ti %d\n", frame, slot, dci_payload.frequency_domain_assignment.val, @@ -1047,10 +1088,17 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.tb_scaling, dci_payload.ndi, dci_payload.rv, - dci_payload.tpc); + dci_payload.tpc, + pucch->timing_indicator); const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = bwp ? (f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0) : NR_DL_DCI_FORMAT_1_0; + int dci_format; + if (sched_ctrl->search_space) { + dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; + } + else { + dci_format = NR_DL_DCI_FORMAT_1_0; + } const int rnti_type = NR_RNTI_C; fill_dci_pdu_rel15(scc, @@ -1105,7 +1153,7 @@ void nr_schedule_ue_spec(module_id_t module_id, /* next, get RLC data */ // const int lcid = DL_SCH_LCID_DTCH; - const int lcid = loop_dcch_dtch; + const int lcid = sched_ctrl->lcid_to_schedule; int dlsch_total_bytes = 0; if (sched_ctrl->num_total_bytes > 0) { tbs_size_t len = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f707e6efeb..f1005cea70 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -29,11 +29,8 @@ */ #include "nr_mac_gNB.h" -#include "SCHED_NR/sched_nr.h" #include "NR_MAC_gNB/mac_proto.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" -#include "PHY/NR_TRANSPORT/nr_dlsch.h" -#include "PHY/NR_TRANSPORT/nr_dci.h" #include "executables/nr-softmodem.h" #include "LAYER2/NR_MAC_COMMON/nr_mac.h" #include "executables/softmodem-common.h" @@ -56,7 +53,7 @@ //#define UL_HARQ_PRINT extern RAN_CONTEXT_t RC; -const uint8_t nr_rv_round_map[4] = {0, 2, 1, 3}; +const uint8_t nr_rv_round_map[4] = {0, 2, 3, 1}; //#define ENABLE_MAC_PAYLOAD_DEBUG 1 //uint8_t mac_pdu[MAX_NR_DLSCH_PAYLOAD_BYTES]; @@ -283,6 +280,7 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; /* find largest unallocated chunk */ const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; int rbSize = 0; if (target_dl_bw>bwpSize) @@ -291,11 +289,11 @@ void nr_preprocessor_phytest(module_id_t module_id, /* loop ensures that we allocate exactly target_dl_bw, or return */ while (true) { /* advance to first free RB */ - while (rbStart < bwpSize && vrb_map[rbStart]) + while (rbStart < bwpSize && vrb_map[rbStart + BWPStart]) rbStart++; rbSize = 1; /* iterate until we are at target_dl_bw or no available RBs */ - while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize] && rbSize < target_dl_bw) + while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize + BWPStart] && rbSize < target_dl_bw) rbSize++; /* found target_dl_bw? */ if (rbSize == target_dl_bw) @@ -322,11 +320,19 @@ void nr_preprocessor_phytest(module_id_t module_id, 0, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; + sched_ctrl->lcid_to_schedule = lcid; uint8_t nr_of_candidates; - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); + const int cid = sched_ctrl->coreset->controlResourceSetId; const uint16_t Y = UE_info->Y[UE_id][cid][slot]; const int m = UE_info->num_pdcch_cand[UE_id][cid]; @@ -342,7 +348,7 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE_id); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1,0); if (alloc < 0) { LOG_D(MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", @@ -368,12 +374,11 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_pdsch->rbStart = rbStart; sched_pdsch->rbSize = rbSize; const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; - const uint8_t num_dmrs_cdm_grps_no_data = 1; + const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; ps->nrOfLayers = target_dl_Nl; - if (ps->time_domain_allocation != tda || ps->numDmrsCdmGrpsNoData != num_dmrs_cdm_grps_no_data) + if (ps->time_domain_allocation != tda) nr_set_pdsch_semi_static( - scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, num_dmrs_cdm_grps_no_data, ps); - + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, f, ps); sched_pdsch->mcs = target_dl_mcs; sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); @@ -393,7 +398,7 @@ void nr_preprocessor_phytest(module_id_t module_id, /* mark the corresponding RBs as used */ for (int rb = 0; rb < sched_pdsch->rbSize; rb++) - vrb_map[rb + sched_pdsch->rbStart] = 1; + vrb_map[rb + sched_pdsch->rbStart + BWPStart] = 1; if ((frame&127) == 0) LOG_D(MAC,"phytest: %d.%d DL mcs %d, DL rbStart %d, DL rbSize %d\n", frame, slot, sched_pdsch->mcs, rbStart,rbSize); } @@ -449,14 +454,17 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, NULL,dci_format, tda, num_dmrs_cdm_grps_no_data, ps); uint16_t rbStart = 0; uint16_t rbSize; const int bw = NRRIV2BW(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); if (target_ul_bw>bw) rbSize = bw; @@ -467,7 +475,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; const uint16_t symb = ((1 << ps->nrOfSymbols) - 1) << ps->startSymbolIndex; for (int i = rbStart; i < rbStart + rbSize; ++i) { - if ((vrb_map_UL[i] & symb) != 0) { + if ((vrb_map_UL[i+BWPStart] & symb) != 0) { LOG_E(MAC, "%s(): %4d.%2d RB %d is already reserved, cannot schedule UE\n", __func__, @@ -482,9 +490,16 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ sched_ctrl->sched_pusch.frame = sched_frame; uint8_t nr_of_candidates; - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); + const int cid = sched_ctrl->coreset->controlResourceSetId; const uint16_t Y = UE_info->Y[UE_id][cid][slot]; const int m = UE_info->num_pdcch_cand[UE_id][cid]; @@ -529,6 +544,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* mark the corresponding RBs as used */ for (int rb = rbStart; rb < rbStart + rbSize; rb++) - vrb_map_UL[rb] = 1; + vrb_map_UL[rb+BWPStart] = 1; return true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 1948959d55..7387bfe698 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -30,6 +30,7 @@ */ +#include #include "assertions.h" #include "NR_MAC_gNB/nr_mac_gNB.h" @@ -152,27 +153,33 @@ void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { } } -NR_ControlResourceSet_t *get_coreset(NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp, +NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, + NR_ServingCellConfigCommon_t *scc, + void *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type) { NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space NR_ControlResourceSet_t *coreset; - if (bwp) coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - else if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) + if(coreset_id == 0) { + coreset = RC.nrmac[module_idP]->sched_ctrlCommon->coreset; // this is coreset 0 + } else if (bwp) { + coreset = ((NR_BWP_Downlink_t*)bwp)->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; + } else if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) { coreset = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - else coreset = NULL; + } else { + coreset = NULL; + } if (coreset) AssertFatal(coreset_id == coreset->controlResourceSetId, "ID of common ss coreset does not correspond to id set in the " "search space\n"); return coreset; } else { - const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; + const int n = ((NR_BWP_DownlinkDedicated_t*)bwp)->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; for (int i = 0; i < n; i++) { NR_ControlResourceSet_t *coreset = - bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; + ((NR_BWP_DownlinkDedicated_t*)bwp)->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; if (coreset_id == coreset->controlResourceSetId) { return coreset; } @@ -212,8 +219,8 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, int coreset_id = coreset->controlResourceSetId; int *cce_list; - if(bwp == NULL || bwp->bwp_Id == 0) { - cce_list = nr_mac->cce_list[0][0]; + if(bwp == NULL) { + cce_list = nr_mac->cce_list[0][coreset_id]; } else { cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; } @@ -231,6 +238,8 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, const uint16_t N_cce = N_reg / NR_NB_REG_PER_CCE; const uint16_t M_s_max = nr_of_candidates; + LOG_D(PHY,"allocate_NR_CCes : bwp_id %d, coreset_id %d : N_cce %d, m %d, nr_of_candidates %d, Y %d\n", + (int)(bwp ? bwp->bwp_Id : 0),coreset_id,N_cce,m,nr_of_candidates, Y); //PDCCH candidate index m in CORESET exceeds the maximum number of PDCCH candidates if(m >= nr_of_candidates) return -1; @@ -266,7 +275,7 @@ bool nr_find_nb_rb(uint16_t Qm, return true; /* is the minimum enough? */ - *nb_rb = 1; + *nb_rb = 5; *tbs = nr_compute_tbs(Qm, R, *nb_rb, nb_symb_sch, nb_dmrs_prb, 0, 0, 1) >> 3; if (bytes <= *tbs) return true; @@ -295,6 +304,7 @@ bool nr_find_nb_rb(uint16_t Qm, void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, const NR_BWP_Downlink_t *bwp, + const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, const long dci_format, NR_pdsch_semi_static_t *ps) @@ -308,14 +318,19 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, const int mapping_type = tdaList->list.array[tda]->mappingType; const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); + NR_BWP_DownlinkDedicated_t *bwpd; + + if (bwp && bwp->bwp_Dedicated) { + bwpd = bwp->bwp_Dedicated; + } else { + bwpd = (NR_BWP_DownlinkDedicated_t*)bwpd0; + } ps->mcsTableIdx = 0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { - if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) + if (bwpd->pdsch_Config && + bwpd->pdsch_Config->choice.setup && + bwpd->pdsch_Config->choice.setup->mcs_Table) { + if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) ps->mcsTableIdx = 1; else ps->mcsTableIdx = 2; @@ -329,12 +344,14 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, ps->dmrsConfigType = bwp!=NULL ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; ps->N_PRB_DMRS = ps->numDmrsCdmGrpsNoData * (ps->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4); - ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwp ? bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL, scc->dmrs_TypeA_Position, ps->nrOfSymbols, ps->startSymbolIndex, mapping_type); + ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwpd ? bwpd->pdsch_Config->choice.setup : NULL, scc->dmrs_TypeA_Position, ps->nrOfSymbols, ps->startSymbolIndex, mapping_type); ps->N_DMRS_SLOT = get_num_dmrs(ps->dl_dmrs_symb_pos); + LOG_D(NR_MAC,"bwpd0 %p, bwpd %p : Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",bwpd0,bwpd,ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, + const NR_BWP_UplinkDedicated_t *ubwpd, long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, @@ -352,7 +369,7 @@ void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, &ps->startSymbolIndex, &ps->nrOfSymbols); - ps->pusch_Config = ubwp?ubwp->bwp_Dedicated->pusch_Config->choice.setup:NULL; + ps->pusch_Config = ubwp?ubwp->bwp_Dedicated->pusch_Config->choice.setup:(ubwpd ? ubwpd->pusch_Config->choice.setup : NULL); if (ps->pusch_Config == NULL || !ps->pusch_Config->transformPrecoder) ps->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; else @@ -627,6 +644,7 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } void config_uldci(const NR_BWP_Uplink_t *ubwp, + const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, @@ -649,23 +667,25 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; dci_pdu_rel15->tpc = tpc; - if (ubwp) AssertFatal(ubwp->bwp_Dedicated->pusch_Config->choice.setup->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, + const NR_BWP_UplinkDedicated_t *ubwpd2 = (ubwp) ? ubwp->bwp_Dedicated : ubwpd; + + if (ubwpd2) AssertFatal(ubwpd2->pusch_Config->choice.setup->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); switch (dci_format) { case NR_UL_DCI_FORMAT_0_0: dci_pdu_rel15->format_indicator = 0; break; case NR_UL_DCI_FORMAT_0_1: + LOG_D(NR_MAC,"Configuring DCI Format 0_1\n"); dci_pdu_rel15->dai[0].val = 0; //TODO // bwp indicator as per table 7.3.1.1.2-1 in 38.212 dci_pdu_rel15->bwp_indicator.val = n_ubwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator - if (ubwp && - ubwp->bwp_Dedicated && - ubwp->bwp_Dedicated->pusch_Config && - ubwp->bwp_Dedicated->pusch_Config->choice.setup && - ubwp->bwp_Dedicated->pusch_Config->choice.setup->txConfig != NULL) { - AssertFatal(*ubwp->bwp_Dedicated->pusch_Config->choice.setup->txConfig == NR_PUSCH_Config__txConfig_codebook, + if (ubwpd2 && + ubwpd2->pusch_Config && + ubwpd2->pusch_Config->choice.setup && + ubwpd2->pusch_Config->choice.setup->txConfig != NULL) { + AssertFatal(*ubwpd2->pusch_Config->choice.setup->txConfig == NR_PUSCH_Config__txConfig_codebook, "Non Codebook configuration non supported\n"); dci_pdu_rel15->srs_resource_indicator.val = 0; // taking resource 0 for SRS } @@ -703,7 +723,8 @@ int nr_get_default_pucch_res(int pucch_ResourceCommon) { return(default_pucch_csset[pucch_ResourceCommon]); } -void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, +void nr_configure_pdcch(gNB_MAC_INST *gNB_mac, + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, NR_ServingCellConfigCommon_t *scc, @@ -711,9 +732,19 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { int sps; + AssertFatal(*ss->controlResourceSetId == coreset->controlResourceSetId, + "coreset id in SS %ld does not correspond to the one in coreset %ld", + *ss->controlResourceSetId, coreset->controlResourceSetId); + if (bwp) { // This is not for SIB1 - pdcch_pdu->BWPSize = NRRIV2BW(bwp->locationAndBandwidth, MAX_BWP_SIZE); - pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->locationAndBandwidth, MAX_BWP_SIZE); + if(coreset->controlResourceSetId == 0){ + pdcch_pdu->BWPSize = gNB_mac->cset0_bwp_size; + pdcch_pdu->BWPStart = gNB_mac->cset0_bwp_start; + } + else { + pdcch_pdu->BWPSize = NRRIV2BW(bwp->locationAndBandwidth, MAX_BWP_SIZE); + pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->locationAndBandwidth, MAX_BWP_SIZE); + } pdcch_pdu->SubcarrierSpacing = bwp->subcarrierSpacing; pdcch_pdu->CyclicPrefix = (bwp->cyclicPrefix==NULL) ? 0 : *bwp->cyclicPrefix; @@ -721,6 +752,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, sps = bwp->cyclicPrefix == NULL ? 14 : 12; } else { + AssertFatal(type0_PDCCH_CSS_config!=NULL,"type0_PDCCH_CSS_config is null,bwp %p\n",bwp); pdcch_pdu->BWPSize = type0_PDCCH_CSS_config->num_rbs; pdcch_pdu->BWPStart = type0_PDCCH_CSS_config->cset_start_rb; pdcch_pdu->SubcarrierSpacing = type0_PDCCH_CSS_config->scs_pdcch; @@ -747,6 +779,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, for (int i=0;i<6;i++) pdcch_pdu->FreqDomainResource[i] = coreset->frequencyDomainResources.buf[i]; + LOG_D(MAC,"Coreset : BWPstart %d, BWPsize %d, SCS %d, freq %x, , duration %d, \n",pdcch_pdu->BWPStart,pdcch_pdu->BWPSize,(int)pdcch_pdu->SubcarrierSpacing,(int)coreset->frequencyDomainResources.buf[0],(int)coreset->duration); //cce-REG-MappingType pdcch_pdu->CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? @@ -785,6 +818,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *CellGroup, NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, @@ -808,12 +842,12 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, uint16_t O_uci = O_csi + O_ack; - NR_PUSCH_Config_t *pusch_Config = bwp ? bwp->bwp_Dedicated->pusch_Config->choice.setup : NULL; - long *pusch_id = bwp ? pusch_Config->dataScramblingIdentityPUSCH : NULL; + NR_PUSCH_Config_t *pusch_Config = bwp ? bwp->bwp_Dedicated->pusch_Config->choice.setup : bwpd->pusch_Config->choice.setup; + long *pusch_id = pusch_Config ? pusch_Config->dataScramblingIdentityPUSCH : NULL; - if (bwp && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) + if (pusch_Config && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled->scramblingID0; - else if (bwp && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL) + else if (pusch_Config && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL) id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; @@ -838,7 +872,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->sequence_hop_flag = 1; break; default: - AssertFatal(1==0,"Group hopping flag %ld undefined (0,1,2) \n", bwp->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_GroupHopping); + AssertFatal(1==0,"Group hopping flag %ld undefined (0,1,2) \n", pucch_ConfigCommon->pucch_GroupHopping); } if (pucch_ConfigCommon->hoppingId != NULL) @@ -852,34 +886,36 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); pucch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; pucch_pdu->cyclic_prefix = (genericParameters->cyclicPrefix==NULL) ? 0 : *genericParameters->cyclicPrefix; - if (r_pucch<0 || bwp){ - // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP - pucch_Config = bwp ? - bwp->bwp_Dedicated->pucch_Config->choice.setup: - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + if (r_pucch<0 || bwp ){ + LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); + // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP + AssertFatal(bwp!=NULL || bwpd!=NULL,"We need one dedicated configuration for a BWP (neither additional or initial BWP has a dedicated configuration)\n"); + pucch_Config = bwp ? + bwp->bwp_Dedicated->pucch_Config->choice.setup: + bwpd->pucch_Config->choice.setup; - AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, - "PUCCH resourceSetToAddModList is null\n"); + AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, + "PUCCH resourceSetToAddModList is null\n"); - n_set = pucch_Config->resourceSetToAddModList->list.count; - AssertFatal(n_set>0,"PUCCH resourceSetToAddModList is empty\n"); + n_set = pucch_Config->resourceSetToAddModList->list.count; + AssertFatal(n_set>0,"PUCCH resourceSetToAddModList is empty\n"); - LOG_D(NR_MAC, "UCI n_set= %d\n", n_set); + LOG_D(NR_MAC, "UCI n_set= %d\n", n_set); - N2 = 2; - // procedure to select pucch resource id from resource sets according to - // number of uci bits and pucch resource indicator pucch_resource - // ( see table 9.2.3.2 in 38.213) - for (int i=0; iresourceSetToAddModList->list.array[i]; - n_list = pucchresset->resourceList.list.count; - if (pucchresset->pucch_ResourceSetId == 0 && O_uci<3) { - if (pucch_resource < n_list) - resource_id = pucchresset->resourceList.list.array[pucch_resource]; - else - AssertFatal(1==0,"Couldn't fine pucch resource indicator %d in PUCCH resource set %d for %d UCI bits",pucch_resource,i,O_uci); - } - if (pucchresset->pucch_ResourceSetId == 1 && O_uci>2) { + N2 = 2; + // procedure to select pucch resource id from resource sets according to + // number of uci bits and pucch resource indicator pucch_resource + // ( see table 9.2.3.2 in 38.213) + for (int i=0; iresourceSetToAddModList->list.array[i]; + n_list = pucchresset->resourceList.list.count; + if (pucchresset->pucch_ResourceSetId == 0 && O_uci<3) { + if (pucch_resource < n_list) + resource_id = pucchresset->resourceList.list.array[pucch_resource]; + else + AssertFatal(1==0,"Couldn't fine pucch resource indicator %d in PUCCH resource set %d for %d UCI bits",pucch_resource,i,O_uci); + } + if (pucchresset->pucch_ResourceSetId == 1 && O_uci>2) { #if (NR_RRC_VERSION >= MAKE_VERSION(16, 0, 0)) N3 = pucchresset->maxPayloadSize!= NULL ? *pucchresset->maxPayloadSize : 1706; #else @@ -921,6 +957,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->nr_of_symbols = pucchres->format.choice.format0->nrofSymbols; pucch_pdu->start_symbol_index = pucchres->format.choice.format0->startingSymbolIndex; pucch_pdu->sr_flag = O_sr; + pucch_pdu->prb_size = 1; break; case NR_PUCCH_Resource__format_PR_format1 : pucch_pdu->format_type = 1; @@ -929,6 +966,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->start_symbol_index = pucchres->format.choice.format1->startingSymbolIndex; pucch_pdu->time_domain_occ_idx = pucchres->format.choice.format1->timeDomainOCC; pucch_pdu->sr_flag = O_sr; + pucch_pdu->prb_size = 1; break; case NR_PUCCH_Resource__format_PR_format2 : pucch_pdu->format_type = 2; @@ -995,6 +1033,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, AssertFatal(res_found==1,"No PUCCH resource found corresponding to id %ld\n",*resource_id); } else { // this is the default PUCCH configuration, PUCCH format 0 or 1 + LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, bwp %p)\n",r_pucch,bwp); int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; int prboffset = r_pucch/default_pucch_csset[rsetindex]; int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; @@ -1015,6 +1054,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->start_symbol_index = default_pucch_firstsymb[rsetindex]; if (pucch_pdu->format_type == 1) pucch_pdu->time_domain_occ_idx = 0; // check this!! pucch_pdu->sr_flag = O_sr; + pucch_pdu->prb_size=1; } } @@ -1024,7 +1064,21 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, nr_dci_format_t format, int bwp_id) { - NR_BWP_Downlink_t *bwp=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; + AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); + + const NR_BWP_DownlinkDedicated_t *bwpd = NULL; + const NR_PDSCH_Config_t *pdsch_Config = NULL; + const NR_PDCCH_Config_t *pdcch_Config = NULL; + + if (bwp_id>0) { + bwpd=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + } + else { + bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + } + pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; + pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; + switch(format) { case NR_UL_DCI_FORMAT_0_1: @@ -1047,22 +1101,22 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, if (CellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig != NULL) AssertFatal(1==0,"Cross Carrier Scheduling Config currently not supported\n"); //vrb to prb mapping - if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver==NULL) + if (pdsch_Config->vrb_ToPRB_Interleaver==NULL) dci_pdu_rel15->vrb_to_prb_mapping.val = 0; else dci_pdu_rel15->vrb_to_prb_mapping.val = 1; //bundling size indicator - if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling) + if (pdsch_Config->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling) AssertFatal(1==0,"Dynamic PRB bundling type currently not supported\n"); //rate matching indicator - uint16_t msb = (bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1==NULL)?0:1; - uint16_t lsb = (bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2==NULL)?0:1; + uint16_t msb = (pdsch_Config->rateMatchPatternGroup1==NULL)?0:1; + uint16_t lsb = (pdsch_Config->rateMatchPatternGroup2==NULL)?0:1; dci_pdu_rel15->rate_matching_indicator.val = lsb | (msb<<1); // aperiodic ZP CSI-RS trigger - if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) + if (pdsch_Config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) AssertFatal(1==0,"Aperiodic ZP CSI-RS currently not supported\n"); // transmission configuration indication - if (bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]->tci_PresentInDCI != NULL) + if (pdcch_Config->controlResourceSetToAddModList->list.array[0]->tci_PresentInDCI != NULL) AssertFatal(1==0,"TCI in DCI currently not supported\n"); //srs resource set if (CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching!=NULL) { @@ -1086,7 +1140,9 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, else dci_pdu_rel15->srs_request.val = 0; // CBGTI and CBGFI - if (CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) + if (CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && + CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) AssertFatal(1==0,"CBG transmission currently not supported\n"); break; default : @@ -1106,10 +1162,10 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint8_t fsize = 0, pos = 0; uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; - int dci_size = nr_dci_size(scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, N_RB, bwp_id); + *dci_pdu=0; + int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP,scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, N_RB, bwp_id); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); - if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) prepare_dci(CellGroup, dci_pdu_rel15, dci_format, bwp_id); @@ -1123,8 +1179,8 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, pos = fsize; *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos)); LOG_D(NR_MAC, - "frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n", - dci_pdu_rel15->frequency_domain_assignment.val, + "RA_RNTI, size %d frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n", + dci_size,dci_pdu_rel15->frequency_domain_assignment.val, fsize, N_RB, dci_size - pos, @@ -1133,7 +1189,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, pos += 4; *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val & 0xf) << (dci_size - pos)); LOG_D(NR_MAC, - "time-domain assignment %d (3 bits)=> %d (0x%lx)\n", + "time-domain assignment %d (4 bits)=> %d (0x%lx)\n", dci_pdu_rel15->time_domain_assignment.val, dci_size - pos, *dci_pdu); @@ -1148,15 +1204,11 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, // MCS pos += 5; *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); -#ifdef DEBUG_FILL_DCI - LOG_I(NR_MAC, "mcs %d (5 bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, dci_size - pos, *dci_pdu); -#endif + LOG_D(NR_MAC, "mcs %d (5 bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, dci_size - pos, *dci_pdu); // TB scaling pos += 2; *dci_pdu |= ((uint64_t)dci_pdu_rel15->tb_scaling & 0x3) << (dci_size - pos); -#ifdef DEBUG_FILL_DCI - LOG_I(NR_MAC, "tb_scaling %d (2 bits)=> %d (0x%lx)\n", dci_pdu_rel15->tb_scaling, dci_size - pos, *dci_pdu); -#endif + LOG_D(NR_MAC, "tb_scaling %d (2 bits)=> %d (0x%lx)\n", dci_pdu_rel15->tb_scaling, dci_size - pos, *dci_pdu); break; case NR_RNTI_C: @@ -1164,7 +1216,8 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, pos++; *dci_pdu |= ((uint64_t)1) << (dci_size - pos); LOG_D(NR_MAC, - "Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n", + "DCI1_0 (size %d): Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n", + dci_size, dci_pdu_rel15->format_indicator, 1, N_RB, @@ -1292,28 +1345,28 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, pos = 1; // Freq domain assignment 0-16 bit fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - LOG_D(PHY, "fsize = %i\n", fsize); + LOG_D(NR_MAC, "fsize = %i\n", fsize); for (int i = 0; i < fsize; i++) *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); - LOG_D(PHY, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); // Time domain assignment 4 bit for (int i = 0; i < 4; i++) *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); - LOG_D(PHY, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); // VRB to PRB mapping 1 bit *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); - LOG_D(PHY, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); + LOG_D(NR_MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); // MCS 5bit //bit over 32, so dci_pdu ++ for (int i = 0; i < 5; i++) *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); - LOG_D(PHY, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); // Redundancy version 2bit for (int i = 0; i < 2; i++) *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++); - LOG_D(PHY, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); // System information indicator 1bit *dci_pdu |= ((uint64_t)dci_pdu_rel15->system_info_indicator&1)<<(dci_size-pos++); - LOG_D(PHY, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); + LOG_D(NR_MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); break; case NR_RNTI_TC: @@ -1374,6 +1427,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_UL_DCI_FORMAT_0_0: switch (rnti_type) { case NR_RNTI_C: + LOG_D(NR_MAC,"Filling format 0_0 DCI for CRNTI (size %d bits, format ind %d)\n",dci_size,dci_pdu_rel15->format_indicator); // indicating a UL DCI format 1bit pos=1; *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); @@ -1481,6 +1535,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_UL_DCI_FORMAT_0_1: switch (rnti_type) { case NR_RNTI_C: + LOG_D(NR_MAC,"Filling NR_UL_DCI_FORMAT_0_1 size %d format indicator %d\n",dci_size,dci_pdu_rel15->format_indicator); // Indicating a DL DCI format 1bit pos = 1; *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 0x1) << (dci_size - pos); @@ -1559,6 +1614,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_DL_DCI_FORMAT_1_1: // Indicating a DL DCI format 1bit + LOG_D(NR_MAC,"Filling Format 1_1 DCI of size %d\n",dci_size); pos = 1; *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 0x1) << (dci_size - pos); // Carrier indicator @@ -1895,6 +1951,9 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); sched_ctrl->lcid_mask = 0; + if (!get_softmodem_params()->phy_test && !get_softmodem_params()->do_ra && !get_softmodem_params()->sa) { + sched_ctrl->lcid_mask = 1<ta_frame = 0; sched_ctrl->ta_update = 31; sched_ctrl->ta_apply = false; @@ -1915,11 +1974,12 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG const int bwp_id = 1; sched_ctrl->active_bwp = bwpList ? bwpList->list.array[bwp_id - 1] : NULL; const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; - sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); - if (*sched_ctrl->search_space->controlResourceSetId == 0) - sched_ctrl->coreset = RC.nrmac[mod_idP]->sched_ctrlCommon->coreset; // this is coreset 0 - else - sched_ctrl->coreset = get_coreset(scc, sched_ctrl->active_bwp, sched_ctrl->search_space, target_ss); + sched_ctrl->search_space = get_searchspace(scc, + sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, + target_ss); + sched_ctrl->coreset = get_coreset(mod_idP, scc, + sched_ctrl->active_bwp ? (void*)sched_ctrl->active_bwp->bwp_Dedicated : NULL, + sched_ctrl->search_space, target_ss); const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; if (ubwpList) AssertFatal(ubwpList->list.count == 1, "uplinkBWP_ToAddModList has %d BWP!\n", @@ -1946,7 +2006,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); create_nr_list(&sched_ctrl->feedback_ul_harq, 16); create_nr_list(&sched_ctrl->retrans_ul_harq, 16); - LOG_I(NR_MAC, "[gNB %d] Add NR UE_id %d : rnti %x\n", + LOG_D(NR_MAC, "[gNB %d] Add NR UE_id %d : rnti %x\n", mod_idP, UE_id, rntiP); @@ -2036,8 +2096,8 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { // al values passed to this function are x10 int snrx10 = (cqi*5) - 640; if (snrx10 > target + incr) return 0; // decrease 1dB - if (snrx10 < target - incr) return 2; // increase 1dB if (snrx10 < target - (3*incr)) return 3; // increase 3dB + if (snrx10 < target - incr) return 2; // increase 1dB LOG_D(NR_MAC,"tpc : target %d, snrx10 %d\n",target,snrx10); return 1; // no change } @@ -2045,34 +2105,61 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { void get_pdsch_to_harq_feedback(int Mod_idP, int UE_id, + int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, + int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { - int bwp_id=1; NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; - NR_BWP_Downlink_t *bwp=NULL; - NR_BWP_Uplink_t *ubwp=NULL; + NR_BWP_DownlinkDedicated_t *bwpd=NULL; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; - if (CellGroup && CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) - bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - if (CellGroup && CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) - ubwp = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]; + if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { + AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE_id %d\n",UE_id); + AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); + } + if (bwp_id>0) { + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList!=NULL, + "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList is null\n"); + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList!=NULL, + "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList is null\n"); + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count >= bwp_id, + "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count %d < bwp_id %d\n", + CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count,bwp_id); + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count >= bwp_id, + "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count %d < bwp_id %d\n", + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,bwp_id); + bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + } + else if (CellGroup) { // this is an initialBWP + AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, + "CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP is null\n"); + AssertFatal((ubwpd=CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP)!=NULL, + "CellGroup->spCellConfig->spCellConfigDedicated->uplnikConfig->initialUplinkBWP is null\n"); + } NR_SearchSpace_t *ss=NULL; // common search type uses DCI format 1_0 if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { - for (int i=0; i<8; i++) + for (int i=0; i<8; i++) { pdsch_to_harq_feedback[i] = i+1; + if(pdsch_to_harq_feedback[i]>*max_fb_time) + *max_fb_time = pdsch_to_harq_feedback[i]; + } } else { // searching for a ue specific search space int found=0; - - for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + AssertFatal(bwpd->pdcch_Config!=NULL,"bwpd->pdcch_Config is null\n"); + AssertFatal(bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL, + "bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList is null\n"); + for (int i=0;ipdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { + ss=bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); if (ss->searchSpaceType->present == ss_type) { @@ -2084,13 +2171,20 @@ void get_pdsch_to_harq_feedback(int Mod_idP, if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0) { - for (int i=0; i<8; i++) + for (int i=0; i<8; i++) { pdsch_to_harq_feedback[i] = i+1; + if(pdsch_to_harq_feedback[i]>*max_fb_time) + *max_fb_time = pdsch_to_harq_feedback[i]; + } } else { - if(ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL) { - for (int i=0; i<8; i++) - pdsch_to_harq_feedback[i] = *ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[i]; + AssertFatal(ubwpd!=NULL,"ubwpd shouldn't be null here\n"); + if(ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL) { + for (int i=0; i<8; i++) { + pdsch_to_harq_feedback[i] = *ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[i]; + if(pdsch_to_harq_feedback[i]>*max_fb_time) + *max_fb_time = pdsch_to_harq_feedback[i]; + } } else AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n"); @@ -2174,20 +2268,20 @@ void nr_csirs_scheduling(int Mod_idP, csirs_pdu_rel15->row = 1; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row1.buf[0])>>4)&0x0f; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2: csirs_pdu_rel15->row = 2; csirs_pdu_rel15->freq_domain = (((resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]>>4)&0x0f) | ((resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]<<8)&0xff0)); for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4: csirs_pdu_rel15->row = 4; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row4.buf[0])>>5)&0x07; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other: csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.other.buf[0])>>2)&0x3f; @@ -2198,18 +2292,18 @@ void nr_csirs_scheduling(int Mod_idP, case NR_CSI_RS_ResourceMapping__nrofPorts_p2: csirs_pdu_rel15->row = 3; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p4: csirs_pdu_rel15->row = 5; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p8: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 8; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); } else{ int num_k = 0; @@ -2218,12 +2312,12 @@ void nr_csirs_scheduling(int Mod_idP, if(num_k==4) { csirs_pdu_rel15->row = 6; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); } else { csirs_pdu_rel15->row = 7; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); } } break; @@ -2231,12 +2325,12 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 10; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); } else { csirs_pdu_rel15->row = 9; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); } break; case NR_CSI_RS_ResourceMapping__nrofPorts_p16: @@ -2245,24 +2339,24 @@ void nr_csirs_scheduling(int Mod_idP, else csirs_pdu_rel15->row = 11; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p24: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 14; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 15; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (7 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (7 << csirs_pdu_rel15->symb_l0); } else { csirs_pdu_rel15->row = 13; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); } } break; @@ -2270,18 +2364,18 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 17; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 18; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= (7 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (7 << csirs_pdu_rel15->symb_l0); } else { csirs_pdu_rel15->row = 16; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); } } break; @@ -2304,12 +2398,19 @@ bool find_free_CCE(module_id_t module_id, int UE_id){ NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id]; uint8_t nr_of_candidates; - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space); + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<0) break; + } + AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); const int cid = sched_ctrl->coreset->controlResourceSetId; const uint16_t Y = RC.nrmac[module_id]->UE_info.Y[UE_id][cid][slot]; const int m = RC.nrmac[module_id]->UE_info.num_pdcch_cand[UE_id][cid]; + if (UE_id >= 0) LOG_D(NR_MAC,"calling allocate_nr_CCEs with L %d, nr_of_candidates %d, Y %x\n",sched_ctrl->aggregation_level,nr_of_candidates,Y); sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], sched_ctrl->active_bwp, sched_ctrl->coreset, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 6fcc3fe5c1..6a4ccc0d65 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -60,8 +60,9 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, memset(pucch_pdu, 0, sizeof(nfapi_nr_pucch_pdu_t)); future_ul_tti_req->n_pdus += 1; - LOG_D(MAC, - "%4d.%2d Scheduling pucch reception in %4d.%2d: bits SR %d, ACK %d, CSI %d on res %d\n", + LOG_D(NR_MAC, + "%s %4d.%2d Scheduling pucch reception in %4d.%2d: bits SR %d, DAI %d, CSI %d on res %d\n", + pucch->dai_c>0 ? "pucch_acknak" : "", frame, slot, pucch->frame, @@ -72,10 +73,17 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, pucch->resource_indicator); NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; + NR_CellGroupConfig_t *cg=UE_info->CellGroup[UE_id]; + + NR_BWP_UplinkDedicated_t *ubwpd; + ubwpd = cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; + + LOG_D(NR_MAC,"pucch_acknak: %d.%d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch in %d.%d\n",frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); nr_configure_pucch(pucch_pdu, scc, UE_info->CellGroup[UE_id], UE_info->UE_sched_ctrl[UE_id].active_ubwp, + ubwpd, UE_info->rnti[UE_id], pucch->resource_indicator, pucch->csi_bits, @@ -284,10 +292,9 @@ uint8_t compute_ri_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, } return max_ri; } - else { + else AssertFatal(1==0,"Other configurations not yet implemented\n"); - return 0; - } + return -1; } void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, @@ -382,13 +389,11 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in // setting the CSI or SSB index list if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP == csi_report->reportQuantity_type) { - AssertFatal(csi_MeasConfig->csi_SSB_ResourceSetToAddModList != NULL, - "Wrong settings! Report quantity is SSB-RSRP but csi_MeasConfig->csi_SSB_ResourceSetToAddModList is NULL\n"); for (int csi_idx = 0; csi_idx < csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; csi_idx++) { if (csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceSetId == *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.array[0])){ //We can configure only one SSB resource set from spec 38.331 IE CSI-ResourceConfig - nb_resources = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.count; + nb_resources= csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.count; csi_report->SSB_Index_list = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.array; csi_report->CSI_Index_list = NULL; break; @@ -489,7 +494,7 @@ void nr_csi_meas_reporting(int Mod_idP, // preparation is done in first slot of tdd period if (frame % (period / n_slots_frame) != offset / n_slots_frame) continue; - LOG_D(MAC, "CSI reporting in frame %d slot %d\n", frame, sched_slot); + LOG_D(NR_MAC, "CSI reporting in frame %d slot %d\n", frame, sched_slot); const NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0]; const NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[1]; // set with formats >1 @@ -516,6 +521,11 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->csi_bits += nr_get_csi_bitlen(Mod_idP,UE_id,csi_report_id); + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? + &sched_ctrl->active_ubwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; const int m = pucch_Config->resourceToAddModList->list.count; @@ -546,7 +556,7 @@ void nr_csi_meas_reporting(int Mod_idP, } // verify resources are free for (int i = start; i < start + len; ++i) { - vrb_map_UL[i] |= mask; + vrb_map_UL[i+bwp_start] |= mask; } } } @@ -572,7 +582,7 @@ static void handle_dl_harq(module_id_t mod_id, harq->ndi ^= 1; NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; stats->dlsch_errors++; - LOG_D(MAC, "retransmission error for UE %d (total %d)\n", UE_id, stats->dlsch_errors); + LOG_D(NR_MAC, "retransmission error for UE %d (total %d)\n", UE_id, stats->dlsch_errors); } else { add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid); harq->round++; @@ -598,7 +608,7 @@ int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, int Mod_idP, i else if(tci->qcl_Type2 != NULL && tci->qcl_Type2->referenceSignal.present == NR_QCL_Info__referenceSignal_PR_ssb) { if(tci->qcl_Type2->referenceSignal.choice.ssb == ssb_index_t) return tci->tci_StateId; // returned TCI state ID - } else LOG_I(MAC,"SSB index is not found in first 64 TCI states of TCI_statestoAddModList[%d]", i); + } else LOG_I(NR_MAC,"SSB index is not found in first 64 TCI states of TCI_statestoAddModList[%d]", i); } } @@ -722,7 +732,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { stats->cumul_rsrp += strongest_ssb_rsrp; stats->num_rsrp_meas++; ssb_rsrp[idx * nb_of_csi_ssb_report] = strongest_ssb_rsrp; - LOG_D(MAC,"ssb_rsrp = %d\n",strongest_ssb_rsrp); + LOG_D(NR_MAC,"ssb_rsrp = %d\n",strongest_ssb_rsrp); //if current ssb rsrp is greater than better rsrp if(ssb_rsrp[idx * nb_of_csi_ssb_report] > better_rsrp_reported) { @@ -745,7 +755,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { if(ssb_index[target_ssb_beam_index] != ssb_index[curr_ssb_beam_index] && ssb_rsrp[target_ssb_beam_index] > ssb_rsrp[curr_ssb_beam_index]) { if( ssb_rsrp[target_ssb_beam_index] - ssb_rsrp[curr_ssb_beam_index] > L1_RSRP_HYSTERIS) { is_triggering_ssb_beam_switch = 1; - LOG_D(MAC, "Triggering ssb beam switching using tci\n"); + LOG_D(NR_MAC, "Triggering ssb beam switching using tci\n"); } } @@ -1033,7 +1043,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl /* old feedbacks we missed: mark for retransmission */ while (harq->feedback_frame != frame || (harq->feedback_frame == frame && harq->feedback_slot < slot)) { - LOG_W(MAC, + LOG_W(NR_MAC, "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the past)\n", pid, harq->feedback_frame, @@ -1049,7 +1059,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl } /* feedbacks that we wait for in the future: don't do anything */ if (harq->feedback_slot > slot) { - LOG_W(MAC, + LOG_W(NR_MAC, "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the future)\n", pid, harq->feedback_frame, @@ -1068,7 +1078,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, { int UE_id = find_nr_UE_id(mod_id, uci_01->rnti); if (UE_id < 0) { - LOG_E(MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_01->rnti); + LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_01->rnti); return; } NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; @@ -1086,6 +1096,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); handle_dl_harq(mod_id, UE_id, pid, harq_value == 1 && harq_confidence == 0); + if (harq_confidence == 1) UE_info->mac_stats[UE_id].pucch0_DTX++; } } @@ -1093,13 +1104,14 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, if (uci_01->pduBitmap & 0x1 && uci_01->sr->sr_indication && uci_01->sr->sr_confidence_level == 0 && uci_01->ul_cqi >= 148) { // SR detected with SNR >= 10dB sched_ctrl->SR |= true; - LOG_D(MAC, "SR UE %04x ul_cqi %d\n", uci_01->rnti, uci_01->ul_cqi); + LOG_D(NR_MAC, "SR UE %04x ul_cqi %d\n", uci_01->rnti, uci_01->ul_cqi); } // tpc (power control) only if we received AckNack or positive SR. For a // negative SR, the UE won't have sent anything, and the SNR is not valid if (((uci_01->pduBitmap >> 1) & 0x1) || sched_ctrl->SR) { - sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); + if ((uci_01->harq) && (uci_01->harq->harq_confidence_level==0)) sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); + else sched_ctrl->tpc1 = 3; sched_ctrl->pucch_snrx10 = uci_01->ul_cqi * 5 - 640; } } @@ -1111,7 +1123,7 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, { int UE_id = find_nr_UE_id(mod_id, uci_234->rnti); if (UE_id < 0) { - LOG_E(MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); + LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); return; } AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id],"Cellgroup is null for UE %d/%x\n",UE_id,uci_234->rnti); @@ -1162,15 +1174,16 @@ int nr_acknack_scheduling(int mod_id, int UE_id, frame_t frame, sub_frame_t slot, - int r_pucch) -{ + int r_pucch, + int is_common) { + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; - const int nr_ulmix_slots = tdd->nrofUplinkSlots + (tdd->nrofUplinkSymbols != 0); const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; const int first_ul_slot_tdd = tdd->nrofDownlinkSlots + nr_slots_period * (slot / nr_slots_period); + const int first_ul_slot_period = first_ul_slot_tdd%nr_slots_period; const int CC_id = 0; NR_sched_pucch_t *csi_pucch; @@ -1188,6 +1201,7 @@ int nr_acknack_scheduling(int mod_id, * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; + LOG_D(NR_MAC,"pucch_acknak %d.%d Trying to allocate pucch, current DAI %d\n",frame,slot,pucch->dai_c); pucch->r_pucch=r_pucch; AssertFatal(pucch->csi_bits == 0, "%s(): csi_bits %d in sched_pucch[0]\n", @@ -1199,10 +1213,14 @@ int nr_acknack_scheduling(int mod_id, * the same slot again */ const int f = pucch->frame; const int s = pucch->ul_slot; + LOG_D(NR_MAC,"pucch_acknak : %d.%d DAI = 2 pucch currently in %d.%d, advancing by 1 slot\n",frame,slot,f,s); nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; - pucch->ul_slot = (s + 1) % n_slots_frame; + if(((s + 1)%nr_slots_period) == 0) + pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + else + pucch->ul_slot = (s + 1) % n_slots_frame; // we assume that only two indices over the array sched_pucch exist csi_pucch = &sched_ctrl->sched_pucch[1]; // skip the CSI PUCCH if it is present and if in the next frame/slot @@ -1214,30 +1232,40 @@ int nr_acknack_scheduling(int mod_id, && !csi_pucch->simultaneous_harqcsi) { nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); memset(csi_pucch, 0, sizeof(*csi_pucch)); - pucch->frame = s >= n_slots_frame - 2 ? (f + 1) % 1024 : f; - pucch->ul_slot = (s + 2) % n_slots_frame; + pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; + if(((s + 1)%nr_slots_period) == 0) + pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + else + pucch->ul_slot = (s + 1) % n_slots_frame; } } - LOG_D(MAC,"1. DL slot %d, UL_ACK %d\n",slot,pucch->ul_slot); - /* if the UE's next PUCCH occasion is after the possible UL slots (within the - * same frame) or wrapped around to the next frame, then we assume there is - * no possible PUCCH allocation anymore */ - if ((pucch->frame == frame - && (pucch->ul_slot >= first_ul_slot_tdd + nr_ulmix_slots)) - || (pucch->frame == frame + 1)) - return -1; + LOG_D(NR_MAC,"pucch_acknak 1. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n",frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP - NR_SearchSpace__searchSpaceType_PR ss_type = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; - uint8_t pdsch_to_harq_feedback[8]; - get_pdsch_to_harq_feedback(mod_id, UE_id, ss_type, pdsch_to_harq_feedback); + NR_CellGroupConfig_t *cg = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd=NULL; + if (cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) + ubwpd = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + + NR_SearchSpace__searchSpaceType_PR ss_type = (is_common==0 && (sched_ctrl->active_bwp || ubwpd)) ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; + uint8_t pdsch_to_harq_feedback[8]; + int bwp_Id = 0; + if (sched_ctrl->active_ubwp) bwp_Id = sched_ctrl->active_ubwp->bwp_Id; + + int max_fb_time = 0; + get_pdsch_to_harq_feedback(mod_id, UE_id, bwp_Id, ss_type, &max_fb_time, pdsch_to_harq_feedback); + int max_absslot = frame*n_slots_frame + slot + max_fb_time; + + LOG_D(NR_MAC,"pucch_acknak 1b. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n",frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ if (pucch->dai_c > 0) { /* this UE already has a PUCCH occasion */ - DevAssert(pucch->frame == frame); - // Find the right timing_indicator value. int i = 0; while (i < 8) { @@ -1250,50 +1278,63 @@ int nr_acknack_scheduling(int mod_id, const int f = pucch->frame; const int s = pucch->ul_slot; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + LOG_D(NR_MAC,"pucch_acknak : %d.%d DAI > 0, cannot reach timing for pucch in %d.%d, advancing slot by 1 and trying again\n",frame,slot,f,s); nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; - pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, pucch->r_pucch); + if(((s + 1)%nr_slots_period) == 0) + pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + else + pucch->ul_slot = (s + 1) % n_slots_frame; + return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); } pucch->timing_indicator = i; pucch->dai_c++; // retain old resource indicator, and we are good + LOG_D(NR_MAC,"pucch_acknak : %d.%d. DAI > 0, pucch allocated for %d.%d (index %d)\n",frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); return 0; } + LOG_D(NR_MAC,"pucch_acknak : %d.%d DAI = 0, looking for new pucch occasion\n",frame,slot); /* we need to find a new PUCCH occasion */ - /* if time information is outdated (e.g., last PUCCH occasion in last frame), - * set to first possible UL occasion in this frame. Note that if such UE is - * scheduled a lot and used all AckNacks, pucch->frame might have been - * wrapped around to next frame */ - if (frame != pucch->frame || pucch->ul_slot < first_ul_slot_tdd) { + /*Inizialization of timing information*/ + if (pucch->frame == 0 && pucch->ul_slot == 0) { AssertFatal(pucch->sr_flag + pucch->dai_c == 0, "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); - AssertFatal(frame + 1 != pucch->frame, - "frame wrap around not handled in %s() yet\n", - __func__); pucch->frame = frame; pucch->ul_slot = first_ul_slot_tdd; } - // advance ul_slot if it is not reachable by UE - pucch->ul_slot = max(pucch->ul_slot, slot + pdsch_to_harq_feedback[0]); - // Find the right timing_indicator value. - int i = 0; - while (i < 8) { - LOG_D(MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", - i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); - if (pdsch_to_harq_feedback[i] == pucch->ul_slot - slot) + int ind_found = -1; + // while we are within the feedback limits and it has not been + while ((pucch->frame*n_slots_frame + pucch->ul_slot) <= max_absslot) { + int i = 0; + while (i < 8) { + LOG_D(NR_MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", + i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); + if (pdsch_to_harq_feedback[i] == pucch->ul_slot - slot) { + ind_found = i; + break; + } + ++i; + } + if (ind_found!=-1) break; - ++i; + // advance to the next ul slot + const int f = pucch->frame; + const int s = pucch->ul_slot; + pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; + if(((s + 1)%nr_slots_period) == 0) + pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + else + pucch->ul_slot = (s + 1) % n_slots_frame; } - if (i >= 8) { - LOG_W(MAC, + if (ind_found==-1) { + LOG_W(NR_MAC, "%4d.%2d could not find pdsch_to_harq_feedback for UE %d: earliest " "ack slot %d\n", frame, @@ -1305,9 +1346,10 @@ int nr_acknack_scheduling(int mod_id, // is there already CSI in this slot? csi_pucch = &sched_ctrl->sched_pucch[1]; - if (csi_pucch->csi_bits > 0 - && csi_pucch->frame == pucch->frame - && csi_pucch->ul_slot == pucch->ul_slot) { + if (csi_pucch && + csi_pucch->csi_bits > 0 && + csi_pucch->frame == pucch->frame && + csi_pucch->ul_slot == pucch->ul_slot) { // skip the CSI PUCCH if it is present and if in the next frame/slot // and if we don't multiplex // FIXME currently we support at most 11 bits in pucch2 so skip also in that case @@ -1321,24 +1363,27 @@ int nr_acknack_scheduling(int mod_id, const int s = pucch->ul_slot; memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; - pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, -1); + if(((s + 1)%nr_slots_period) == 0) + pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + else + pucch->ul_slot = (s + 1) % n_slots_frame; + return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); } // multiplexing harq and csi in a pucch else { - csi_pucch->timing_indicator = i; + csi_pucch->timing_indicator = ind_found; csi_pucch->dai_c++; return 1; } } - pucch->timing_indicator = i; // index in the list of timing indicators + pucch->timing_indicator = ind_found; // index in the list of timing indicators - LOG_D(MAC,"2. DL slot %d, UL_ACK %d (index %d)\n",slot,pucch->ul_slot,i); + LOG_D(NR_MAC,"pucch_acknak 2. DAI 0 DL %d.%d, UL_ACK %d.%d (index %d)\n",frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); pucch->dai_c++; pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources - + pucch->r_pucch=r_pucch; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; @@ -1351,19 +1396,34 @@ int nr_acknack_scheduling(int mod_id, pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? + &sched_ctrl->active_ubwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + /* verify that at that slot and symbol, resources are free. We only do this * for initialCyclicShift 0 (we assume it always has that one), so other * initialCyclicShifts can overlap with ICS 0!*/ - if (pucch_Config==NULL) - return 0; - const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; - DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - if (resource->format.choice.format0->initialCyclicShift == 0) { - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; - const uint16_t symb = 1 << resource->format.choice.format0->startingSymbolIndex; - if ((vrb_map_UL[resource->startingPRB] & symb) != 0) - LOG_W(MAC, "symbol 0x%x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d.%d\n", symb, resource->startingPRB, pucch->frame, pucch->ul_slot); - vrb_map_UL[resource->startingPRB] |= symb; + + if (pucch_Config) { + const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; + DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); + int second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; + int nr_of_symbols = resource->format.choice.format0->nrofSymbols; + if (resource->format.choice.format0->initialCyclicShift == 0) { + uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + for (int l=0; lformat.choice.format0->startingSymbolIndex + l); + int prb; + if (l==1 && second_hop_prb != 0) + prb = second_hop_prb; + else + prb = resource->startingPRB; + if ((vrb_map_UL[bwp_start+prb] & symb) != 0) + LOG_W(MAC, "symbol 0x%x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d.%d\n", symb, resource->startingPRB, pucch->frame, pucch->ul_slot); + vrb_map_UL[bwp_start+prb] |= symb; + } + } } return 0; } @@ -1381,6 +1441,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + if (sched_ctrl->ul_failure==1) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; @@ -1392,7 +1453,11 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - if (pucch_Config == NULL ) continue; + + else continue; + if (!pucch_Config->schedulingRequestResourceToAddModList) + continue; + AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { @@ -1403,9 +1468,10 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) find_period_offest_SR(SchedulingRequestResourceConfig,&SR_period,&SR_offset); // convert to int to avoid underflow of uint int sfn_sf = SFN * n_slots_frame + slot; + LOG_D(NR_MAC,"SR_resource_id %d: SR_period %d, SR_offset %d\n",SR_resource_id,SR_period,SR_offset); if ((sfn_sf - SR_offset) % SR_period != 0) continue; - LOG_D(MAC, "%4d.%2d Scheduling Request identified\n", SFN, slot); + LOG_D(NR_MAC, "%4d.%2d Scheduling Request identified\n", SFN, slot); NR_PUCCH_ResourceId_t *PucchResourceId = SchedulingRequestResourceConfig->resource; int found = -1; @@ -1437,7 +1503,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) && pdu->initial_cyclic_shift == pucch_res->format.choice.format0->initialCyclicShift && pdu->nr_of_symbols == pucch_res->format.choice.format0->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format0->startingSymbolIndex) { - LOG_D(MAC,"%4d.%2d adding SR_flag 1 to PUCCH nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); pdu->sr_flag = 1; nfapi_allocated = true; break; @@ -1452,7 +1518,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) NR_sched_pucch_t *curr_pucch = &sched_ctrl->sched_pucch[0]; if (curr_pucch->frame == SFN && curr_pucch->ul_slot == slot) { if (curr_pucch->resource_indicator != found) { - LOG_W(MAC, "%4d.%2d expected PUCCH in this slot to have resource indicator of SR (%d), skipping SR\n", SFN, slot, found); + LOG_W(NR_MAC, "%4d.%2d expected PUCCH in this slot to have resource indicator of SR (%d), skipping SR\n", SFN, slot, found); continue; } curr_pucch->sr_flag = true; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 18ba5f612d..9a6fa32b5f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -34,34 +34,21 @@ #include "common/utils/nr/nr_common.h" #include +#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -//38.321 Table 6.1.3.1-1 -const uint32_t NR_SHORT_BSR_TABLE[32] = { - 0, 10, 14, 20, 28, 38, 53, 74, - 102, 142, 198, 276, 384, 535, 745, 1038, - 1446, 2014, 2806, 3909, 5446, 7587, 10570, 14726, -20516, 28581, 39818, 55474, 77284, 107669, 150000, 300000 -}; +int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { -//38.321 Table 6.1.3.1-2 -const uint32_t NR_LONG_BSR_TABLE[256] ={ - 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 25, 26, - 28, 30, 32, 34, 36, 38, 40, 43, 46, 49, 52, 55, 59, 62, 66, 71, - 75, 80, 85, 91, 97, 103, 110, 117, 124, 132, 141, 150, 160, 170, 181, 193, - 205, 218, 233, 248, 264, 281, 299, 318, 339, 361, 384, 409, 436, 464, 494, 526, - 560, 597, 635, 677, 720, 767, 817, 870, 926, 987, 1051, 1119, 1191, 1269, 1351, 1439, - 1532, 1631, 1737, 1850, 1970, 2098, 2234, 2379, 2533, 2698, 2873, 3059, 3258, 3469, 3694, 3934, - 4189, 4461, 4751, 5059, 5387, 5737, 6109, 6506, 6928, 7378, 7857, 8367, 8910, 9488, 10104, 10760, - 11458, 12202, 12994, 13838, 14736, 15692, 16711, 17795, 18951, 20181, 21491, 22885, 24371, 25953, 27638, 29431, - 31342, 33376, 35543, 37850, 40307, 42923, 45709, 48676, 51836, 55200, 58784, 62599, 66663, 70990, 75598, 80505, - 85730, 91295, 97221, 103532, 110252, 117409, 125030, 133146, 141789, 150992, 160793, 171231, 182345, 194182, 206786, 220209, - 234503, 249725, 265935, 283197, 301579, 321155, 342002, 364202, 387842, 413018, 439827, 468377, 498780, 531156, 565634, 602350, - 641449, 683087, 727427, 774645, 824928, 878475, 935498, 996222, 1060888, 1129752, 1203085, 1281179, 1364342, 1452903, 1547213, 1647644, - 1754595, 1868488, 1989774, 2118933, 2256475, 2402946, 2558924, 2725027, 2901912, 3090279, 3290873, 3504487, 3731968, 3974215, 4232186, 4506902, - 4799451, 5110989, 5442750, 5796046, 6172275, 6572925, 6999582, 7453933, 7937777, 8453028, 9001725, 9586039, 10208280, 10870913, 11576557, 12328006, -13128233, 13980403, 14887889, 15854280, 16883401, 17979324, 19146385, 20389201, 21712690, 23122088, 24622972, 26221280, 27923336, 29735875, 31666069, 33721553, -35910462, 38241455, 40723756, 43367187, 46182206, 49179951, 52372284, 55771835, 59392055, 63247269, 67352729, 71724679, 76380419, 81338368, 162676736, 4294967295 -}; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + int dci_format; + if (sched_ctrl->search_space) { + dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; + } + else { + dci_format = NR_UL_DCI_FORMAT_0_0; + } + + return(dci_format); +} void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp) { @@ -164,7 +151,7 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub nrmac->preferred_ul_tda[bwp_id][slot] = 0; else if (tdd && nr_mix_slots && sched_slot % nr_slots_period == tdd->nrofDownlinkSlots) nrmac->preferred_ul_tda[bwp_id][slot] = tdaMi; - LOG_I(MAC, "DL slot %d UL slot %d preferred_ul_tda %d\n", slot, sched_slot, nrmac->preferred_ul_tda[bwp_id][slot]); + LOG_D(MAC, "DL slot %d UL slot %d preferred_ul_tda %d\n", slot, sched_slot, nrmac->preferred_ul_tda[bwp_id][slot]); } if (k2 < tdd->nrofUplinkSlots) @@ -198,7 +185,7 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub // F: length of L is 0:8 or 1:16 bits wide // R: Reserved bit, set to zero. -void nr_process_mac_pdu(module_id_t module_idP, +int nr_process_mac_pdu(module_id_t module_idP, int UE_id, uint8_t CC_id, frame_t frameP, @@ -378,18 +365,22 @@ void nr_process_mac_pdu(module_id_t module_idP, mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; mac_subheader_len = 2; } - LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, UE_info->rnti[UE_id]); - mac_rlc_data_ind(module_idP, - UE_info->rnti[UE_id], - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *) (pduP + mac_subheader_len), - mac_sdu_len, - 1, - NULL); + if (UE_info->CellGroup[UE_id]) { + LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, UE_info->rnti[UE_id]); + mac_rlc_data_ind(module_idP, + UE_info->rnti[UE_id], + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *) (pduP + mac_subheader_len), + mac_sdu_len, + 1, + NULL); + } else { + AssertFatal(1==0,"[UE %d] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE_id,frameP,slot,rx_lcid); + } break; case UL_SCH_LCID_SRB3: // todo @@ -478,7 +469,7 @@ void nr_process_mac_pdu(module_id_t module_idP, default: LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); - return; + return -1; break; } @@ -503,9 +494,10 @@ void nr_process_mac_pdu(module_id_t module_idP, for (int i = 0; i < 20; i++) // Only printf 1st - 20nd bytes printf("%02x ", pduP[i]); printf("\n"); - return; + return 0; } } + return 0; } void abort_nr_ul_harq(module_id_t mod_id, int UE_id, int8_t harq_pid) @@ -627,7 +619,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T_BUFFER(sduP, sdu_lenP)); UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; - LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p\n", + LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p, rssi %d\n", gnb_mod_idP, harq_pid, CC_idP, @@ -637,10 +629,11 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_id, ul_cqi, timing_advance, - sduP); + sduP, + rssi); // if not missed detection (10dB threshold for now) - if (UE_scheduling_control->raw_rssi < 100 + rssi) { + if (rssi>0) { UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); if (timing_advance != 0xffff) UE_scheduling_control->ta_update = timing_advance; @@ -649,7 +642,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); } else{ - UE_scheduling_control->tpc0 = 1; + LOG_D(NR_MAC,"[UE %d] Detected DTX : increasing UE TX power\n",UE_id); + UE_scheduling_control->tpc0 = 3; } #if defined(ENABLE_MAC_PAYLOAD_DEBUG) @@ -757,7 +751,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // re-initialize ta update variables after RA procedure completion UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; - LOG_I(NR_MAC, + LOG_D(NR_MAC, "reset RA state information for RA-RNTI %04x/index %d\n", ra->rnti, i); @@ -770,6 +764,14 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_id, ra->rnti); + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; + + UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); + if (timing_advance != 0xffff) + UE_scheduling_control->ta_update = timing_advance; + UE_scheduling_control->raw_rssi = rssi; + UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; + LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); if(ra->cfra) { LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); @@ -790,13 +792,16 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // First byte corresponds to R/LCID MAC sub-header memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); - nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP); - - ra->state = Msg4; - ra->Msg4_frame = (frameP + 2) % 1024; - ra->Msg4_slot = 1; - LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot); - + if (nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { + ra->state = Msg4; + ra->Msg4_frame = (frameP + 2) % 1024; + ra->Msg4_slot = 1; + LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot); + } + else { + nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); + nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); + } } return; } @@ -864,7 +869,7 @@ bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t * (2) there is a scheduling request * (3) or we did not schedule it in more than 10 frames */ const bool has_data = sched_ctrl->estimated_ul_buffer > sched_ctrl->sched_ul_bytes; - const bool high_inactivity = diff >= nrmac->ulsch_max_slots_inactivity; + const bool high_inactivity = diff >= nrmac->ulsch_max_frame_inactivity * n; LOG_D(NR_MAC, "%4d.%2d UL inactivity %d slots has_data %d SR %d\n", frame, @@ -895,14 +900,16 @@ bool allocate_ul_retransmission(module_id_t module_id, NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; - + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; + int rbStart = 0; // wrt BWP start const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_bwp ? 1 : 2; + const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); + LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { /* Check the resource is enough for retransmission */ while (rbStart < bwpSize && !rballoc_mask[rbStart]) @@ -914,12 +921,13 @@ bool allocate_ul_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since tha last * (re-)transmission */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + + int dci_format = get_dci_format(sched_ctrl); + if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { /* the retransmission will use a different time domain allocation, check @@ -930,9 +938,8 @@ bool allocate_ul_retransmission(module_id_t module_id, while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) rbSize++; NR_pusch_semi_static_t temp_ps; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, &temp_ps); + int dci_format = get_dci_format(sched_ctrl); + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp,ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, &temp_ps); uint32_t new_tbs; uint16_t new_rbSize; bool success = nr_find_nb_rb(retInfo->Qm, @@ -1029,9 +1036,13 @@ void pf_ul(module_id_t module_id, if (UE_info->Msg4_ACKed[UE_id] != true) continue; + LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %d\n",UE_id); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; + int rbStart = 0; // wrt BWP start + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1043,6 +1054,7 @@ void pf_ul(module_id_t module_id, /* Check if retransmission is necessary */ sched_pusch->ul_harq_pid = sched_ctrl->retrans_ul_harq.head; + LOG_D(NR_MAC,"pf_ul: UE %d harq_pid %d\n",UE_id,sched_pusch->ul_harq_pid); if (sched_pusch->ul_harq_pid >= 0) { /* Allocate retransmission*/ bool r = allocate_ul_retransmission( @@ -1051,6 +1063,8 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE_info->rnti[UE_id]); continue; } + else LOG_D(NR_MAC,"%4d.%2d UL Retransmission UE RNTI %04x to be allocated, max_num_ue %d\n",frame,slot,UE_info->rnti[UE_id],max_num_ue); + /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ max_num_ue--; if (max_num_ue < 0) @@ -1062,6 +1076,7 @@ void pf_ul(module_id_t module_id, /* preprocessor computed sched_frame/sched_slot */ const bool do_sched = nr_UE_is_to_be_scheduled(module_id, 0, UE_id, sched_pusch->frame, sched_pusch->slot); + LOG_D(NR_MAC,"pf_ul: do_sched UE %d => %s\n",UE_id,do_sched ? "yes" : "no"); if (B == 0 && !do_sched) continue; @@ -1091,14 +1106,13 @@ void pf_ul(module_id_t module_id, /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether dci_format, TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ - const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_ubwp ? 1 : 2; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; + int dci_format = get_dci_format(sched_ctrl); const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = 9; update_ul_ue_R_Qm(sched_pusch, ps); @@ -1158,6 +1172,7 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); continue; } + else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, UE_info->rnti[UE_id]); /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ max_num_ue--; @@ -1165,6 +1180,8 @@ void pf_ul(module_id_t module_id, return; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); @@ -1182,19 +1199,19 @@ void pf_ul(module_id_t module_id, UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); return; } + else LOG_D(NR_MAC,"allocating UL data for UE %d/RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d\n",UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether dci_format, TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ - const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_ubwp ? 1 : 2; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; + int dci_format = get_dci_format(sched_ctrl); const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); update_ul_ue_R_Qm(sched_pusch, ps); /* Calculate the current scheduling bytes and the necessary RBs */ @@ -1211,8 +1228,8 @@ void pf_ul(module_id_t module_id, &rbSize); sched_pusch->rbSize = rbSize; sched_pusch->tb_size = TBS; - LOG_D(NR_MAC,"rbSize %d, TBS %d, est buf %d, sched_ul %d, B %d\n", - rbSize, sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B); + LOG_D(NR_MAC,"rbSize %d, TBS %d, est buf %d, sched_ul %d, B %d, CCE %d, num_dmrs_symb %d, N_PRB_DMRS %d\n", + rbSize, sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B,sched_ctrl->cce_index,ps->num_dmrs_symb,ps->N_PRB_DMRS); /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; @@ -1276,6 +1293,10 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpStart = NRRIV2PRBOFFSET(sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, + MAX_BWP_SIZE); const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -1285,11 +1306,14 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; int st = 0, e = 0, len = 0; + for (int i = 0; i < bwpSize; i++) + if (RC.nrmac[module_id]->ulprbbl[i] == 1) vrb_map_UL[i]=symb; + for (int i = 0; i < bwpSize; i++) { - while ((vrb_map_UL[i] & symb) != 0 && i < bwpSize) + while ((vrb_map_UL[bwpStart + i] & symb) != 0 && i < bwpSize) i++; st = i; - while ((vrb_map_UL[i] & symb) == 0 && i < bwpSize) + while ((vrb_map_UL[bwpStart + i] & symb) == 0 && i < bwpSize) i++; if (i - st > len) { len = i - st; @@ -1298,6 +1322,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t } st = e - len + 1; + LOG_D(NR_MAC,"UL %d.%d : start_prb %d, end PRB %d\n",frame,slot,st,e); + uint8_t rballoc_mask[bwpSize]; /* Calculate mask: if any RB in vrb_map_UL is blocked (1), the current RB will be 0 */ @@ -1373,6 +1399,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; + + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; UE_info->mac_stats[UE_id].ulsch_current_bytes = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in @@ -1444,24 +1473,28 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) sched_ctrl->last_ul_slot = sched_pusch->slot; LOG_D(NR_MAC, - "%4d.%2d RNTI %04x UL sched %4d.%2d start %2d RBS %3d startSymbol %2d nb_symbol %2d MCS %2d TBS %4d HARQ PID %2d round %d NDI %d est %6d sched %6d est BSR %6d\n", + "ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n", frame, slot, rnti, sched_pusch->frame, sched_pusch->slot, + sched_ctrl->aggregation_level, sched_pusch->rbStart, sched_pusch->rbSize, ps->startSymbolIndex, ps->nrOfSymbols, + ps->ul_dmrs_symb_pos, sched_pusch->mcs, sched_pusch->tb_size, harq_id, cur_harq->round, + nr_rv_round_map[cur_harq->round], cur_harq->ndi, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, - sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); + sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, + sched_ctrl->tpc0); /* PUSCH in a later slot, but corresponding DCI now! */ @@ -1500,8 +1533,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->mcs_index = sched_pusch->mcs; pusch_pdu->mcs_table = ps->mcs_table; pusch_pdu->transform_precoding = ps->transform_precoding; - if (ps->pusch_Config && - ps->pusch_Config->dataScramblingIdentityPUSCH) + if (ps->pusch_Config && ps->pusch_Config->dataScramblingIdentityPUSCH) pusch_pdu->data_scrambling_id = *ps->pusch_Config->dataScramblingIdentityPUSCH; else pusch_pdu->data_scrambling_id = *scc->physCellId; @@ -1553,6 +1585,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported + LOG_D(NR_MAC,"PUSCH PDU : data_scrambling_identity %x, dmrs_scrambling_id %x\n",pusch_pdu->data_scrambling_id,pusch_pdu->ul_dmrs_scrambling_id); /* TRANSFORM PRECODING --------------------------------------------------------*/ if (pusch_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled){ @@ -1592,8 +1625,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* look up the PDCCH PDU for this BWP and CORESET. If it does not exist, * create it */ const int bwpid = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - NR_SearchSpace_t *ss = sched_ctrl->active_bwp ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; - NR_ControlResourceSet_t *coreset = sched_ctrl->active_bwp? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; + NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; + NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = pdcch_pdu_bwp_coreset[bwpid][coresetid]; if (!pdcch_pdu) { @@ -1603,11 +1636,11 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu, ss, coreset, scc, genericParameters, NULL); + nr_configure_pdcch(nr_mac, pdcch_pdu, ss, coreset, scc, genericParameters, NULL); pdcch_pdu_bwp_coreset[bwpid][coresetid] = pdcch_pdu; } - LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frame,slot); + LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %x\n", frame,slot,sched_ctrl->cce_index,rnti); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; @@ -1628,14 +1661,12 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; int n_ubwp=1; - if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) - n_ubwp = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) + n_ubwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; config_uldci(sched_ctrl->active_ubwp, + ubwpd, scc, pusch_pdu, &uldci_payload, @@ -1645,7 +1676,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) n_ubwp, bwpid); fill_dci_pdu_rel15(scc, - CellGroup, + cg, dci_pdu, &uldci_payload, ps->dci_format, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 391b98af36..3b275ca8a0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -31,8 +31,6 @@ #ifndef __LAYER2_NR_MAC_PROTO_H__ #define __LAYER2_NR_MAC_PROTO_H__ -#include "PHY/defs_gNB.h" - #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "NR_TAG-Id.h" @@ -53,10 +51,10 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, int pusch_AntennaPorts, int sib1_tda, NR_ServingCellConfigCommon_t *scc, - int nsa_flag, + NR_BCCH_BCH_Message_t *mib, + int add_ue, uint32_t rnti, - NR_CellGroupConfig_t *CellGroup - ); + NR_CellGroupConfig_t *CellGroup); void clear_nr_nfapi_information(gNB_MAC_INST * gNB, int CC_idP, @@ -178,7 +176,8 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, void config_uldci(const NR_BWP_Uplink_t *ubwp, - const NR_ServingCellConfigCommon_t *scc, + const NR_BWP_UplinkDedicated_t *ubwpd, + const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -204,11 +203,14 @@ int nr_acknack_scheduling(int Mod_idP, int UE_id, frame_t frameP, sub_frame_t slotP, - int r_pucch); + int r_pucch, + int do_common); void get_pdsch_to_harq_feedback(int Mod_idP, int UE_id, + int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, + int *max_fb_time, uint8_t *pdsch_to_harq_feedback); void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, @@ -234,6 +236,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *CellGroup, NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, @@ -245,7 +248,8 @@ void find_search_space(int ss_type, NR_BWP_Downlink_t *bwp, NR_SearchSpace_t *ss); -void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, +void nr_configure_pdcch(gNB_MAC_INST *gNB_mac, + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, NR_ServingCellConfigCommon_t *scc, @@ -267,8 +271,9 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, int bwp_id); /* find coreset within the search space */ -NR_ControlResourceSet_t *get_coreset(NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp, +NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, + NR_ServingCellConfigCommon_t *scc, + void *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type); @@ -282,12 +287,14 @@ long get_K2(NR_ServingCellConfigCommon_t *scc, NR_BWP_Uplink_t *ubwp, int time_d void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, const NR_BWP_Downlink_t *bwp, + const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, const long dci_format, NR_pdsch_semi_static_t *ps); void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, + const NR_BWP_UplinkDedicated_t *ubwpd, long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, @@ -435,4 +442,5 @@ bool nr_find_nb_rb(uint16_t Qm, void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); +void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen); #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 117c18ae8d..6e13e4bcc6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -45,6 +45,86 @@ extern RAN_CONTEXT_t RC; +#define MACSTATSSTRLEN 16384 + +void *nrmac_stats_thread(void *arg) { + + gNB_MAC_INST *gNB = (gNB_MAC_INST *)arg; + + char output[MACSTATSSTRLEN]; + memset(output,0,MACSTATSSTRLEN); + FILE *fd=fopen("nrMAC_stats.log","w"); + AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); + + while (oai_exit == 0) { + dump_mac_stats(gNB,output,MACSTATSSTRLEN); + fprintf(fd,"%s\n",output); + fflush(fd); + usleep(200000); + fseek(fd,0,SEEK_SET); + } + fclose(fd); + return (void *)0; +} + +void clear_mac_stats(gNB_MAC_INST *gNB) { + memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); +} + +void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen) +{ + NR_UE_info_t *UE_info = &gNB->UE_info; + int num = 1; + + int stroff=0; + if (UE_info->num_UEs == 0) return; + + for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { + + stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm\n", + UE_id, + UE_info->rnti[UE_id], + num++, + UE_info->num_UEs, + UE_info->UE_sched_ctrl[UE_id].ph, + UE_info->UE_sched_ctrl[UE_id].pcmax); + + NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; + stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, pucch0_DTX %d average RSRP %d (%d meas)\n", + UE_id, + stats->dlsch_rounds[0], stats->dlsch_rounds[1], + stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, + stats->pucch0_DTX, + avg_rsrp, stats->num_rsrp_meas); + stats->num_rsrp_meas = 0; + stats->cumul_rsrp = 0 ; + stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); + stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", + UE_id, + stats->ulsch_rounds[0], stats->ulsch_rounds[1], + stats->ulsch_rounds[2], stats->ulsch_rounds[3], + stats->ulsch_DTX, + stats->ulsch_errors); + stroff+=sprintf(output+stroff, + "UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n", + UE_id, + stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); + for (int lc_id = 0; lc_id < 63; lc_id++) { + if (stats->lc_bytes_tx[lc_id] > 0) { + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); + } + if (stats->lc_bytes_rx[lc_id] > 0) { + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); + } + } + } + print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL); +} + + void mac_top_init_gNB(void) { module_id_t i; @@ -90,6 +170,7 @@ void mac_top_init_gNB(void) RC.nrmac[i]->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(i, 0); RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); } + pthread_create(&RC.nrmac[i]->stats_thread,NULL,nrmac_stats_thread,(void*)RC.nrmac[i]); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) @@ -103,6 +184,7 @@ void mac_top_init_gNB(void) rrc_init_nr_global_param(); + } else { RC.nrmac = NULL; } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 22da5223c0..699b92a831 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -145,6 +145,8 @@ typedef struct { uint8_t msg3_first_rb; /// Msg3 number of RB uint8_t msg3_nb_rb; + /// Msg3 BWP start + uint8_t msg3_bwp_start; /// Msg3 TPC command uint8_t msg3_TPC; /// Msg3 ULdelay command @@ -529,7 +531,8 @@ typedef struct { /// corresponding to the sched_pusch/sched_pdsch structures below int cce_index; uint8_t aggregation_level; - + /// maximum aggregation level for UE, can be used to select level + int maxL; /// PUCCH scheduling information. Array of two: HARQ+SR in the first field, /// CSI in second. This order is important for nr_acknack_scheduling()! NR_sched_pucch_t sched_pucch[2]; @@ -563,6 +566,7 @@ typedef struct { mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID]; int lcid_mask; + int lcid_to_schedule; uint16_t ta_frame; int16_t ta_update; bool ta_apply; @@ -616,6 +620,7 @@ typedef struct { int ulsch_total_bytes_scheduled; int ulsch_total_bytes_rx; int ulsch_current_bytes; + int pucch0_DTX; int cumul_rsrp; uint8_t num_rsrp_meas; } NR_mac_stats_t; @@ -662,6 +667,7 @@ typedef struct gNB_MAC_INST_s { NR_TAG_t *tag; /// Pointer to IF module instance for PHY NR_IF_Module_t *if_inst; + pthread_t stats_thread; /// Pusch target SNR int pusch_target_snrx10; /// Pucch target SNR @@ -678,7 +684,8 @@ typedef struct gNB_MAC_INST_s { NR_COMMON_channels_t common_channels[NFAPI_CC_MAX]; /// current PDU index (BCH,DLSCH) uint16_t pdu_index[NFAPI_CC_MAX]; - + int num_ulprbbl; + int ulprbbl[275]; /// NFAPI Config Request Structure nfapi_nr_config_request_scf_t config[NFAPI_CC_MAX]; /// NFAPI DL Config Request Structure @@ -743,7 +750,7 @@ typedef struct gNB_MAC_INST_s { int *preferred_ul_tda[MAX_NUM_BWP]; /// maximum number of slots before a UE will be scheduled ULSCH automatically - uint32_t ulsch_max_slots_inactivity; + uint32_t ulsch_max_frame_inactivity; /// DL preprocessor for differentiated scheduling nr_pp_impl_dl pre_processor_dl; @@ -751,6 +758,8 @@ typedef struct gNB_MAC_INST_s { nr_pp_impl_ul pre_processor_ul; NR_UE_sched_ctrl_t *sched_ctrlCommon; + uint16_t cset0_bwp_start; + uint16_t cset0_bwp_size; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config[64]; bool first_MIB; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index cc44572abd..05e77a935d 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -603,7 +603,7 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) //int optval; int bytes_received; sidelink_pc5s_element *sl_pc5s_msg_send = NULL; - pc5s_header_t *pc5s_header = NULL; + pc5s_header_t *pc5s_header = NULL; rb_id_t rab_id = 0; //TTN for D2D (PC5S) // receive a message from ProSe App @@ -704,6 +704,12 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) pc5s_header->rb_id, rab_id, pc5s_header->data_size); + /* pointers to pc5s_header fields possibly not aligned because pc5s_header points to a packed structure + * Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and + * gcc, from v9, now warns about it. fix these warnings by using local variables + */ + uint32_t sourceL2Id = pc5s_header->sourceL2Id; + uint32_t destinationL2Id = pc5s_header->destinationL2Id; pdcp_data_req( &ctxt, SRB_FLAG_NO, @@ -713,9 +719,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) pc5s_header->data_size, (unsigned char *)receive_buf, PDCP_TRANSMISSION_MODE_DATA, - &pc5s_header->sourceL2Id, - &pc5s_header->destinationL2Id + &sourceL2Id, + &destinationL2Id ); + pc5s_header->sourceL2Id = sourceL2Id; + pc5s_header->destinationL2Id=destinationL2Id; } else { /* else of h_rc == HASH_TABLE_OK */ MSC_LOG_RX_DISCARDED_MESSAGE( (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, @@ -759,6 +767,12 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) pc5s_header->rb_id, DEFAULT_RAB_ID, pc5s_header->data_size); + /* pointers to pc5s_header fields possibly not aligned because pc5s_header points to a packed structure + * Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and + * gcc, from v9, now warns about it. fix these warnings by using local variables + */ + uint32_t sourceL2Id = pc5s_header->sourceL2Id; + uint32_t destinationL2Id = pc5s_header->destinationL2Id; pdcp_data_req ( &ctxt, SRB_FLAG_NO, @@ -768,9 +782,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) pc5s_header->data_size, (unsigned char *)receive_buf, PDCP_TRANSMISSION_MODE_DATA, - &pc5s_header->sourceL2Id, - &pc5s_header->destinationL2Id + &sourceL2Id, + &destinationL2Id ); + pc5s_header->sourceL2Id = sourceL2Id; + pc5s_header->destinationL2Id=destinationL2Id; } } /* end of !ctxt.enb_flag */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index fff1db6da6..62aa101a50 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -102,6 +102,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, entity->rb_id, rcvd_count, entity->is_gnb ? 0 : 1); if (memcmp(integrity, buffer + size - integrity_size, 4) != 0) { LOG_E(PDCP, "discard NR PDU, integrity failed\n"); +// return; } } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c deleted file mode 100644 index 73840aeb0a..0000000000 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 "nr_pdcp_entity_srb.h" - -#include -#include -#include - -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(entity->common.deliver_sdu_data, - (nr_pdcp_entity_t *)entity, buffer+2, size-6); -} - -void nr_pdcp_entity_srb_recv_sdu(nr_pdcp_entity_t *_entity, char *buffer, int size, - int sdu_id) -{ - nr_pdcp_entity_srb_t *entity = (nr_pdcp_entity_srb_t *)_entity; - int sn; - char buf[size+6]; - - sn = entity->common.next_nr_pdcp_tx_sn; - - entity->common.next_nr_pdcp_tx_sn++; - if (entity->common.next_nr_pdcp_tx_sn > entity->common.maximum_nr_pdcp_sn) { - entity->common.next_nr_pdcp_tx_sn = 0; - entity->common.tx_hfn++; - } - - buf[0] = (sn >> 8) & 0x0f; - buf[1] = sn & 0xff; - memcpy(buf+2, buffer, size); - - /* For now use padding for the MAC-I bytes (normally carrying message authentication code) - * which come after the data payload bytes (38.323, section 6.2.2.1) */ - for (int i=size+2; icommon.deliver_pdu(entity->common.deliver_pdu_data, - (nr_pdcp_entity_t *)entity, buf, size+6, sdu_id); -} - -void nr_pdcp_entity_srb_set_integrity_key(nr_pdcp_entity_t *_entity, char *key) -{ - /* nothing to do */ -} - -void nr_pdcp_entity_srb_delete(nr_pdcp_entity_t *_entity) -{ - nr_pdcp_entity_srb_t *entity = (nr_pdcp_entity_srb_t *)_entity; - free(entity); -} - diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 35ef057527..f9a6838443 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -36,6 +36,7 @@ #include "pdcp.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include +#include "openair2/SDAP/nr_sdap/nr_sdap_gnb.h" #define TODO do { \ printf("%s:%d:%s: todo\n", __FILE__, __LINE__, __FUNCTION__); \ @@ -443,10 +444,18 @@ 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, to be sent to TUN interface"); - len = write(nas_sock_fd[0], buf, size); + + if(entity->has_sdapDLheader){ + size -= SDAP_HDR_LENGTH; + len = write(nas_sock_fd[0], &buf[SDAP_HDR_LENGTH], size); + } else { + len = write(nas_sock_fd[0], buf, size); + } + if (len != size) { LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); } + } else{ for (i = 0; i < 5; i++) { @@ -471,6 +480,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, sizeof(gtpv1u_gnb_tunnel_data_req_t) + size + GTPU_HEADER_OVERHEAD_MAX - offset); AssertFatal(message_p != NULL, "OUT OF MEMORY"); + gtpv1u_gnb_tunnel_data_req_t *req=>PV1U_GNB_TUNNEL_DATA_REQ(message_p); gtpu_buffer_p = (uint8_t*)(req+1); memcpy(gtpu_buffer_p+GTPU_HEADER_OVERHEAD_MAX, buf+offset, size-offset); @@ -479,8 +489,10 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, req->offset = GTPU_HEADER_OVERHEAD_MAX; req->rnti = ue->rnti; req->pdusession_id = entity->pdusession_id; - if (offset==1) - LOG_I(PDCP, "%s() (drb %d) SDAP header %2x\n",__func__, rb_id, buf[0]); + if (offset==1) { + LOG_I(PDCP, "%s() (drb %d) SDAP header %2x\n",__func__, rb_id, buf[0]); + sdap_gnb_ul_header_handler(buf[0]); // Handler for the UL gNB SDAP Header + } LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size-offset); itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p); } @@ -759,7 +771,11 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) } } -static void add_srb(int is_gnb, int rnti, struct NR_SRB_ToAddMod *s) +static void add_srb(int is_gnb, int rnti, struct NR_SRB_ToAddMod *s, + int ciphering_algorithm, + int integrity_algorithm, + unsigned char *ciphering_key, + unsigned char *integrity_key) { nr_pdcp_entity_t *pdcp_srb; nr_pdcp_ue_t *ue; @@ -780,8 +796,10 @@ static void add_srb(int is_gnb, int rnti, struct NR_SRB_ToAddMod *s) 0, 0, 0, 0, // sdap parameters deliver_sdu_srb, ue, deliver_pdu_srb, ue, 12, t_Reordering, -1, - 0, 0, - NULL, NULL); + ciphering_algorithm, + integrity_algorithm, + ciphering_key, + integrity_key); nr_pdcp_ue_add_srb_pdcp_entity(ue, srb_id, pdcp_srb); LOG_D(PDCP, "%s:%d:%s: added srb %d to ue rnti %x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); @@ -803,12 +821,27 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, int sn_size_dl = decode_sn_size_dl(*s->pdcp_Config->drb->pdcp_SN_SizeDL); int discard_timer = decode_discard_timer(*s->pdcp_Config->drb->discardTimer); + int has_integrity; + int has_ciphering; + /* if pdcp_Config->t_Reordering is not present, it means infinity (-1) */ int t_reordering = -1; if (s->pdcp_Config->t_Reordering != NULL) { t_reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering); } + if (s->pdcp_Config->drb != NULL + && s->pdcp_Config->drb->integrityProtection != NULL) + has_integrity = 1; + else + has_integrity = 0; + + if (s->pdcp_Config->ext1 != NULL + && s->pdcp_Config->ext1->cipheringDisabled != NULL) + has_ciphering = 0; + else + has_ciphering = 1; + if ((!s->cnAssociation) || s->cnAssociation->present == NR_DRB_ToAddMod__cnAssociation_PR_NOTHING) { LOG_E(PDCP,"%s:%d:%s: fatal, cnAssociation is missing or present is NR_DRB_ToAddMod__cnAssociation_PR_NOTHING\n",__FILE__,__LINE__,__FUNCTION__); exit(-1); @@ -829,10 +862,6 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, 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; - if (has_sdapDLheader==1) { - LOG_E(PDCP,"%s:%d:%s: fatal, no support for SDAP DL yet\n",__FILE__,__LINE__,__FUNCTION__); - exit(-1); - } } /* TODO(?): accept different UL and DL SN sizes? */ if (sn_size_ul != sn_size_dl) { @@ -850,15 +879,17 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, nr_pdcp_manager_lock(nr_pdcp_ue_manager); ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); if (ue->drb[drb_id-1] != NULL) { - LOG_D(PDCP, "%s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n", + LOG_W(PDCP, "%s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } else { pdcp_drb = new_nr_pdcp_entity(NR_PDCP_DRB_AM, is_gnb, drb_id,pdusession_id,has_sdap, has_sdapULheader,has_sdapDLheader, deliver_sdu_drb, ue, deliver_pdu_drb, ue, sn_size_dl, t_reordering, discard_timer, - ciphering_algorithm, integrity_algorithm, - ciphering_key, integrity_key); + has_ciphering ? ciphering_algorithm : 0, + has_integrity ? integrity_algorithm : 0, + has_ciphering ? ciphering_key : NULL, + has_integrity ? integrity_key : NULL); 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); @@ -902,9 +933,7 @@ boolean_t nr_rrc_pdcp_config_asn1_req( uint8_t *const kRRCint, uint8_t *const kUPenc, uint8_t *const kUPint -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 -#endif ,rb_id_t *const defaultDRB, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list) //struct NR_RLC_Config *rlc_Config) @@ -932,7 +961,9 @@ boolean_t nr_rrc_pdcp_config_asn1_req( if (srb2add_list != NULL) { for (i = 0; i < srb2add_list->list.count; i++) { - add_srb(ctxt_pP->enb_flag,rnti, srb2add_list->list.array[i]); + add_srb(ctxt_pP->enb_flag,rnti, srb2add_list->list.array[i], + security_modeP & 0x0f, (security_modeP >> 4) & 0x0f, + kRRCenc, kRRCint); } } @@ -972,9 +1003,7 @@ boolean_t rrc_pdcp_config_asn1_req( uint8_t *const kRRCenc, uint8_t *const kRRCint, uint8_t *const kUPenc -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 -#endif ,rb_id_t *const defaultDRB) { return 0; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 17af5611f1..7d2ce30494 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -270,7 +270,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( + buf_stat.retx_size + buf_stat.tx_size; } else { - if (!(frameP%128)) //to supress this warning message + if (!(frameP%128)) //to suppress this warning message LOG_W(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rntiP %x\n", __FUNCTION__, channel_idP, rntiP); ret.bytes_in_buffer = 0; } @@ -334,6 +334,8 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( + buf_stat.retx_size + buf_stat.tx_size; } else { + if (!(frameP%128)) //to suppress this warning message + LOG_W(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rntiP %x\n", __FUNCTION__, channel_idP, rntiP); ret = 0; } @@ -399,15 +401,22 @@ int rlc_module_init(int enb_flag) { static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static int inited = 0; + static int inited_ue = 0; if (pthread_mutex_lock(&lock)) abort(); - if (inited) { - LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + if (enb_flag == 1 && inited) { + LOG_E(RLC, "%s:%d:%s: fatal, inited already 1\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } - inited = 1; + if (enb_flag == 0 && inited_ue) { + LOG_E(RLC, "%s:%d:%s: fatal, inited_ue already 1\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + + if (enb_flag == 1) inited = 1; + if (enb_flag == 0) inited_ue = 1; nr_rlc_ue_manager = new_nr_rlc_ue_manager(enb_flag); @@ -962,16 +971,16 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt if ((drb2add_listP != NULL) && (rlc_bearer2add_list != NULL)) { for (i = 0; i < drb2add_listP->list.count; i++) { if (rlc_bearer2add_list != NULL) { - 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]); + 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/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index b2230df623..30fb20b727 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -2969,6 +2969,12 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize = siWindowLength_int[sib1->si_WindowLength]; LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", ctxt_pP->module_id, eNB_index, ctxt_pP->module_id ); + /* pointers to SIperiod inthe Info struct points to a packed structure + * Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and + * gcc, from v9, now warns about it. fix these warnings by removing the indirection on data + * Not sure if SiPeriod can be modified, reassign after function call for security + */ + uint16_t Aligned_SIperiod = UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod; rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index, (LTE_RadioResourceConfigCommonSIB_t *)NULL, (struct LTE_PhysicalConfigDedicated *)NULL, @@ -2981,7 +2987,7 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config, (LTE_MobilityControlInfo_t *) NULL, &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize, - &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod, + &Aligned_SIperiod, NULL, NULL, NULL, @@ -2995,6 +3001,7 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, (struct LTE_NonMBSFN_SubframeConfig_r14 *)NULL, (LTE_MBSFN_AreaInfoList_r9_t *)NULL ); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod=Aligned_SIperiod; LOG_I(RRC,"Setting SIStatus bit 0 to 1\n"); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag; diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 1c02c3de46..f5b1db8b8c 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -364,7 +364,7 @@ typedef struct UE_RRC_INFO_s { uint8_t SIwindowsize_MBMS; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40 uint8_t handoverTarget; HO_STATE_t ho_state; - uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120 + uint16_t SIperiod ; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120 uint16_t SIperiod_MBMS; //!< Corresponds to the SIB1-MBMS si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120 TODO unsigned short UE_index; uint32_t T300_active; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index abd015878e..a2115763cc 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -3618,9 +3618,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t NULL, NULL, NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL -#endif , NULL); /* Refresh SRBs/DRBs */ @@ -3629,11 +3627,9 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *SRB_configList2, // NULL, *DRB_configList, NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0 -#endif ); } @@ -6331,9 +6327,7 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct NULL, NULL, NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL -#endif , NULL); /* Refresh SRBs/DRBs */ @@ -6342,11 +6336,9 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct *SRB_configList2, // NULL, *DRB_configList, NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0 -#endif ); } diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index dd9a5bb188..d2d761f817 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -285,7 +285,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id); - AssertFatal(ue_context_p!=NULL,"failed to get ue_context\n"); + AssertFatal(ue_context_p!=NULL,"failed to get ue_context, rnti %x\n",rnti); char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size; // check if data is there for MAC @@ -332,14 +332,16 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, NR_CellGroupConfig_t cellGroupConfig; NR_ServingCellConfigCommon_t *scc=RC.nrrrc[module_idP]->carrier.servingcellconfigcommon; memset(&cellGroupConfig,0,sizeof(cellGroupConfig)); - fill_initial_cellGroupConfig(rntiP,&cellGroupConfig,scc); + + fill_initial_cellGroupConfig(rntiP,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); MessageDef* tmp=itti_alloc_new_message_sized(TASK_RRC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE, sizeof(f1ap_initial_ul_rrc_message_t) + sdu_lenP); f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(tmp); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)&cellGroupConfig, msg->du2cu_rrc_container, - sizeof(msg->du2cu_rrc_container)); + 1024); //sizeof(msg->du2cu_rrc_container)); if (enc_rval.encoded == -1) { LOG_E(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7dc7ba7589..9936fa1c2a 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -451,7 +451,7 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss1->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss1->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss1->monitoringSymbolsWithinSlot)); ss1->monitoringSymbolsWithinSlot->buf = calloc(1,2); - // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed + // should be '1000 0000 0000 00'B (LSB first!), first symbol in slot, adjust if needed ss1->monitoringSymbolsWithinSlot->buf[1] = 0; ss1->monitoringSymbolsWithinSlot->buf[0] = (1<<7); ss1->monitoringSymbolsWithinSlot->size = 2; @@ -459,7 +459,7 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss1->nrofCandidates = calloc(1,sizeof(*ss1->nrofCandidates)); ss1->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; ss1->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - ss1->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4; + ss1->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2; ss1->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; ss1->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; ss1->searchSpaceType = calloc(1,sizeof(*ss1->searchSpaceType)); @@ -987,8 +987,9 @@ uint8_t do_RRCReject(uint8_t Mod_id, } void fill_initial_SpCellConfig(rnti_t rnti, - NR_SpCellConfig_t *SpCellConfig, - NR_ServingCellConfigCommon_t *scc) { + NR_SpCellConfig_t *SpCellConfig, + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier) { SpCellConfig->servCellIndex = NULL; SpCellConfig->reconfigurationWithSync = NULL; @@ -1027,7 +1028,134 @@ void fill_initial_SpCellConfig(rnti_t rnti, pucchres0->format.choice.format0->nrofSymbols=1; pucchres0->format.choice.format0->startingSymbolIndex=13; ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - + initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); + initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; + NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); + initialUplinkBWP->pusch_Config->choice.setup = pusch_Config; + pusch_Config->dataScramblingIdentityPUSCH = NULL; + pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); + *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->dmrs_Type = NULL; + NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NULL; /*calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); + *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0;*/ + NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; + NR_DMRS_UplinkConfig->maxLength=NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; + pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); + pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; + pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); + *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; + pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant)); + *pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = -76; + pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); + NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); + aset->p0_PUSCH_AlphaSetId=0; + aset->p0=calloc(1,sizeof(*aset->p0)); + *aset->p0 = 0; + aset->alpha=calloc(1,sizeof(*aset->alpha)); + *aset->alpha=NR_Alpha_alpha1; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList)); + NR_PUSCH_PathlossReferenceRS_t *plrefRS = calloc(1,sizeof(*plrefRS)); + plrefRS->pusch_PathlossReferenceRS_Id=0; + plrefRS->referenceSignal.present = NR_PathlossReferenceRS_Config_PR_ssb_Index; + plrefRS->referenceSignal.choice.ssb_Index = 0; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,plrefRS); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; + pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; + pusch_Config->pusch_PowerControl->deltaMCS = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList)); + NR_SRI_PUSCH_PowerControl_t *sriPUSCHPC=calloc(1,sizeof(*sriPUSCHPC)); + sriPUSCHPC->sri_PUSCH_PowerControlId=0; + sriPUSCHPC->sri_PUSCH_PathlossReferenceRS_Id=0; + sriPUSCHPC->sri_P0_PUSCH_AlphaSetId=0; + sriPUSCHPC->sri_PUSCH_ClosedLoopIndex=NR_SRI_PUSCH_PowerControl__sri_PUSCH_ClosedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList->list,sriPUSCHPC); + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; + pusch_Config->frequencyHopping=NULL; + pusch_Config->frequencyHoppingOffsetLists=NULL; + pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; + pusch_Config->pusch_TimeDomainAllocationList = NULL; + pusch_Config->pusch_AggregationFactor=NULL; + pusch_Config->mcs_Table=NULL; + pusch_Config->mcs_TableTransformPrecoder=NULL; + pusch_Config->transformPrecoder= NULL; + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { + pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); + *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; + } + pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); + *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; + pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); + *pusch_Config->maxRank= 1; + pusch_Config->rbg_Size=NULL; + pusch_Config->uci_OnPUSCH=NULL; + pusch_Config->tp_pi2BPSK=NULL; + + initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); + initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + initialUplinkBWP->srs_Config->choice.setup=srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition=2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.c_SRS = 0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + // configure Scheduling request // 40 slot period pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); @@ -1036,20 +1164,30 @@ void fill_initial_SpCellConfig(rnti_t rnti, schedulingRequestResourceConfig->schedulingRequestID= 0; schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 8 UEs on this resource (2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 8,9,18,19,28,29,38,39). + // note: make sure that there is no issue here. Later choose the RNTI accordingly. + // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. // Check for above configuration and exit for now if it is not the case AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, - "SCS != 30kHz\n"); + "SCS != 30kHz\n"); AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 10*((rnti>>1)&3) + (rnti&2); + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8 + 10*((rnti>>1)&3) + (rnti&1); schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); *schedulingRequestResourceConfig->resource = 0; ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); + long *delay[8]; + for (int i=0;i<8;i++) { + delay[i] = calloc(1,sizeof(*delay[i])); + AssertFatal(carrier->minRXTXTIMEpdsch >=2 && carrier->minRXTXTIMEpdsch <7, + "check minRXTXTIMEpdsch %d\n",carrier->minRXTXTIMEpdsch); + *delay[i] = (i+carrier->minRXTXTIMEpdsch); + ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); + } + SpCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->initialDownlinkBWP)); NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp_Dedicated->pdcch_Config)); @@ -1057,12 +1195,53 @@ void fill_initial_SpCellConfig(rnti_t rnti, bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup)); bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + + bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); + + NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); + coreset->controlResourceSetId=1; + // frequency domain resources depends on BWP size + // options are 24, 48 or 96 + coreset->frequencyDomainResources.buf = calloc(1,6); + if (0) { + int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; + if (curr_bwp < 48) + coreset->frequencyDomainResources.buf[0] = 0xf0; + else + coreset->frequencyDomainResources.buf[0] = 0xff; + if (curr_bwp < 96) + coreset->frequencyDomainResources.buf[1] = 0; + else + coreset->frequencyDomainResources.buf[1] = 0xff; + } else { + coreset->frequencyDomainResources.buf[0] = 0xf0; + coreset->frequencyDomainResources.buf[1] = 0; + } + coreset->frequencyDomainResources.buf[2] = 0; + coreset->frequencyDomainResources.buf[3] = 0; + coreset->frequencyDomainResources.buf[4] = 0; + coreset->frequencyDomainResources.buf[5] = 0; + coreset->frequencyDomainResources.size = 6; + coreset->frequencyDomainResources.bits_unused = 3; + coreset->duration=1; + coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; + coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; + + coreset->tci_StatesPDCCH_ToAddList=NULL; + coreset->tci_StatesPDCCH_ToReleaseList = NULL; + coreset->tci_PresentInDCI = NULL; + coreset->pdcch_DMRS_ScramblingID = NULL; + + ASN_SEQUENCE_ADD(&bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, + coreset); + + bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); ss2->searchSpaceId=2; ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=0; + *ss2->controlResourceSetId=1; ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; @@ -1075,19 +1254,64 @@ void fill_initial_SpCellConfig(rnti_t rnti, ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); - ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0; + ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; ASN_SEQUENCE_ADD(&bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); - + bwp_Dedicated->pdsch_Config=calloc(1,sizeof(*bwp_Dedicated->pdsch_Config)); + bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup)); + bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; + + bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); + *bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = + calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); + *bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + + bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); + NR_TCI_State_t *tcic; + + tcic=calloc(1,sizeof(*tcic)); + tcic->tci_StateId=0; + tcic->qcl_Type1.cell=NULL; + tcic->qcl_Type1.bwp_Id=NULL; + tcic->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; + tcic->qcl_Type1.referenceSignal.choice.ssb = 0; + tcic->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeD; + + ASN_SEQUENCE_ADD(&bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic); + SpCellConfig->spCellConfigDedicated->tag_Id=0; + SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig)); + NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig)); + SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup; + SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; + pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; + pdsch_servingcellconfig->xOverhead = NULL; + pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); + *pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16; + pdsch_servingcellconfig->pucch_Cell= NULL; + pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1)); + pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); + *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; + } void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, uint8_t SRB_config_present, uint8_t DRB_config_present) { @@ -1164,7 +1388,7 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr rlc_Config_drb->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; rlc_Config_drb->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; rlc_Config_drb->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; - rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t4; + rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); @@ -1192,8 +1416,9 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupC } void fill_initial_cellGroupConfig(rnti_t rnti, - NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc) { + NR_CellGroupConfig_t *cellGroupConfig, + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier) { NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; NR_RLC_Config_t *rlc_Config = NULL; @@ -1246,15 +1471,17 @@ void fill_initial_cellGroupConfig(rnti_t rnti, /* mac CellGroup Config */ if (1) { mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig)); - mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist; - schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); - schedulingrequestlist->schedulingRequestId = 0; - schedulingrequestlist->sr_ProhibitTimer = CALLOC(1,sizeof(*schedulingrequestlist->sr_ProhibitTimer)); - *(schedulingrequestlist->sr_ProhibitTimer) = 0; - schedulingrequestlist->sr_TransMax = 0; - ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + if (1) { + mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); + mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + struct NR_SchedulingRequestToAddMod *schedulingrequestlist; + schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); + schedulingrequestlist->schedulingRequestId = 0; + schedulingrequestlist->sr_ProhibitTimer = CALLOC(1,sizeof(*schedulingrequestlist->sr_ProhibitTimer)); + *(schedulingrequestlist->sr_ProhibitTimer) = 0; + schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; + ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + } mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config)); mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80; @@ -1276,13 +1503,13 @@ void fill_initial_cellGroupConfig(rnti_t rnti, physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig)); physicalCellGroupConfig->p_NR_FR1 = calloc(1,sizeof(*physicalCellGroupConfig->p_NR_FR1)); - *physicalCellGroupConfig->p_NR_FR1 = 20; + *physicalCellGroupConfig->p_NR_FR1 = 10; physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook = NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic; cellGroupConfig->physicalCellGroupConfig = physicalCellGroupConfig; cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(rnti,cellGroupConfig->spCellConfig,scc); + fill_initial_SpCellConfig(rnti,cellGroupConfig->spCellConfig,scc,carrier); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; @@ -1292,8 +1519,9 @@ void fill_initial_cellGroupConfig(rnti_t rnti, uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t *const buffer, const uint8_t transaction_id, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc) + OCTET_STRING_t *masterCellGroup_from_DU, + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier) //------------------------------------------------------------------------------ { asn_enc_rval_t enc_rval; @@ -1360,7 +1588,7 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, } else { cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,cellGroupConfig,scc); + fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,cellGroupConfig,scc,carrier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 4b248b8f1f..f4486aaf4d 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -100,11 +100,13 @@ uint8_t do_RRCReject(uint8_t Mod_id, void fill_initial_SpCellConfig(rnti_t rnti, NR_SpCellConfig_t *SpCellConfig, - NR_ServingCellConfigCommon_t *scc); + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier); void fill_initial_cellGroupConfig(rnti_t rnti, NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc); + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier); void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup); @@ -114,7 +116,8 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t *const buffer, const uint8_t transaction_id, OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc); + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier); uint8_t do_NR_SecurityModeCommand( const protocol_ctxt_t *const ctxt_pP, diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 19120e8854..f33560f122 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -450,8 +450,7 @@ typedef struct { int sib1_tda; int pdsch_AntennaPorts; int pusch_AntennaPorts; - int pusch_TargetSNRx10; - int pucch_TargetSNRx10; + int minRXTXTIMEpdsch; int do_CSIRS; NR_BCCH_DL_SCH_Message_t *siblock1; NR_ServingCellConfigCommon_t *servingcellconfigcommon; @@ -474,6 +473,10 @@ typedef struct { /* nia0 = 0, nia1 = 1, ... */ int integrity_algorithms[4]; int integrity_algorithms_count; + + /* flags to enable/disable ciphering and integrity for DRBs */ + int do_drb_ciphering; + int do_drb_integrity; } nr_security_configuration_t; //---NR---(completely change)--------------------- diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index c3f415ee64..31165d8195 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -113,9 +113,7 @@ extern boolean_t nr_rrc_pdcp_config_asn1_req( uint8_t *const kRRCint, uint8_t *const kUPenc, uint8_t *const kUPint - #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 - #endif ,rb_id_t *const defaultDRB, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); @@ -264,6 +262,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration rrc->carrier.pusch_AntennaPorts, rrc->carrier.sib1_tda, (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon, + &rrc->carrier.mib, 0, 0, // WIP hardcoded rnti (NR_CellGroupConfig_t *)NULL @@ -355,6 +354,7 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu rrc->carrier.ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset; rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts; rrc->carrier.pusch_AntennaPorts = configuration->pusch_AntennaPorts; + rrc->carrier.minRXTXTIMEpdsch = configuration->minRXTXTIMEpdsch; rrc->carrier.sib1_tda = configuration->sib1_tda; rrc->carrier.do_CSIRS = configuration->do_CSIRS; /// System Information INIT @@ -415,6 +415,7 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, rrc->carrier.pusch_AntennaPorts, rrc->carrier.sib1_tda, NULL, + NULL, 0, ue_context_pP->ue_context.rnti, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : (NR_CellGroupConfig_t *)NULL); @@ -435,7 +436,7 @@ void apply_pdcp_config(rrc_gNB_ue_context_t *const ue_context_pP, ue_context_pP->ue_context.SRB_configList, NULL, NULL, - 0xff, + 0, NULL, NULL, NULL, @@ -457,7 +458,7 @@ rrc_gNB_generate_RRCSetup( ) //----------------------------------------------------------------------------- { - LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup \n"); + LOG_D(NR_RRC, "rrc_gNB_generate_RRCSetup \n"); MessageDef *message_p; // T(T_GNB_RRC_SETUP, @@ -466,17 +467,18 @@ rrc_gNB_generate_RRCSetup( // T_INT(ctxt_pP->subframe), // T_INT(ctxt_pP->rnti)); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP, (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), masterCellGroup_from_DU, - scc); + scc,&rrc->carrier); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(ue_p->Srb0.Tx_buffer.Payload), ue_p->Srb0.Tx_buffer.payload_size, "[MSG] RRC Setup\n"); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + switch (rrc->node_type) { case ngran_gNB_CU: // create an ITTI message @@ -485,7 +487,7 @@ rrc_gNB_generate_RRCSetup( ue_context_pP->ue_context.SRB_configList, NULL, NULL, - 0xff, + 0, NULL, NULL, NULL, @@ -589,7 +591,7 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), NULL, - scc); + scc,&rrc_instance_p->carrier); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(ue_p->Srb0.Tx_buffer.Payload), @@ -606,6 +608,7 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( rrc_instance_p->carrier.pusch_AntennaPorts, rrc_instance_p->carrier.sib1_tda, (NR_ServingCellConfigCommon_t *)rrc_instance_p->carrier.servingcellconfigcommon, + &rrc_instance_p->carrier.mib, 0, ue_context_pP->ue_context.rnti, (NR_CellGroupConfig_t *)NULL @@ -966,6 +969,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( ) //----------------------------------------------------------------------------- { + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; NR_DRB_ToAddMod_t *DRB_config = NULL; NR_SRB_ToAddMod_t *SRB2_config = NULL; NR_SDAP_Config_t *sdap_config = NULL; @@ -1030,7 +1034,7 @@ 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_absent; + sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present; 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)); @@ -1063,9 +1067,20 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( DRB_config->pdcp_Config->moreThanOneRLC = NULL; DRB_config->pdcp_Config->t_Reordering = calloc(1, sizeof(*DRB_config->pdcp_Config->t_Reordering)); - *DRB_config->pdcp_Config->t_Reordering = NR_PDCP_Config__t_Reordering_ms750; + *DRB_config->pdcp_Config->t_Reordering = NR_PDCP_Config__t_Reordering_ms0; DRB_config->pdcp_Config->ext1 = NULL; + if (rrc->security.do_drb_integrity) { + DRB_config->pdcp_Config->drb->integrityProtection = calloc(1, sizeof(*DRB_config->pdcp_Config->drb->integrityProtection)); + *DRB_config->pdcp_Config->drb->integrityProtection = NR_PDCP_Config__drb__integrityProtection_enabled; + } + + if (!rrc->security.do_drb_ciphering) { + DRB_config->pdcp_Config->ext1 = calloc(1, sizeof(*DRB_config->pdcp_Config->ext1)); + DRB_config->pdcp_Config->ext1->cipheringDisabled = calloc(1, sizeof(*DRB_config->pdcp_Config->ext1->cipheringDisabled)); + *DRB_config->pdcp_Config->ext1->cipheringDisabled = NR_PDCP_Config__ext1__cipheringDisabled_true; + } + // Reference TS23501 Table 5.7.4-1: Standardized 5QI to QoS characteristics mapping for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pduSession[i].param.nb_qos; qos_flow_index++) { switch (ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].fiveQI) { @@ -1310,6 +1325,7 @@ rrc_gNB_process_RRCReconfigurationComplete( uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; + uint8_t *kUPint = NULL; NR_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid]; NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; @@ -1319,21 +1335,22 @@ rrc_gNB_process_RRCReconfigurationComplete( ue_context_pP->ue_context.ue_reestablishment_timer = 0; -#ifndef PHYSIM /* Derive the keys from kgnb */ if (DRB_configList != NULL) { - derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, - ue_context_pP->ue_context.kgnb, - &kUPenc); + nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kgnb, + &kUPenc); + nr_derive_key_up_int(ue_context_pP->ue_context.integrity_algorithm, + ue_context_pP->ue_context.kgnb, + &kUPint); } - derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, - ue_context_pP->ue_context.kgnb, - &kRRCenc); - derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, - ue_context_pP->ue_context.kgnb, - &kRRCint); -#endif + nr_derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kgnb, + &kRRCenc); + nr_derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, + ue_context_pP->ue_context.kgnb, + &kRRCint); /* Refresh SRBs/DRBs */ MSC_LOG_TX_MESSAGE(MSC_RRC_GNB, MSC_PDCP_ENB, NULL, 0, MSC_AS_TIME_FMT" CONFIG_REQ UE %x DRB (security unchanged)", MSC_AS_TIME_ARGS(ctxt_pP), @@ -1346,11 +1363,12 @@ rrc_gNB_process_RRCReconfigurationComplete( SRB_configList, // NULL, DRB_configList, DRB_Release_configList2, - 0, // already configured during the securitymodecommand + (ue_context_pP->ue_context.integrity_algorithm << 4) + | ue_context_pP->ue_context.ciphering_algorithm, kRRCenc, kRRCint, kUPenc, - NULL, + kUPint, NULL, NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); @@ -1362,6 +1380,7 @@ rrc_gNB_process_RRCReconfigurationComplete( rrc->carrier.pusch_AntennaPorts, rrc->carrier.sib1_tda, NULL, + NULL, 0, ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup @@ -1793,7 +1812,7 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( nr_rrc_pdcp_config_security( ctxt_pP, ue_context_pP, - send_security_mode_command); + send_security_mode_command ? 0 : 1); LOG_D(NR_RRC, "set security successfully \n"); } @@ -2569,6 +2588,9 @@ rrc_gNB_decode_dcch( xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); } + /* configure ciphering */ + nr_rrc_pdcp_config_security(ctxt_pP, ue_context_p, 1); + rrc_gNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); //rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); break; @@ -2885,7 +2907,7 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { f1_setup_req->mib[i], f1_setup_req->mib_length[i]); AssertFatal(dec_rval.code == RC_OK, - "[gNB_DU %"PRIu8"] Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n", + "[gNB_CU %"PRIu8"] Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n", j, dec_rval.consumed ); NR_BCCH_BCH_Message_t *mib = &rrc->carrier.mib; @@ -3950,7 +3972,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { ctxt_pP->module_id, ue_context_p, NGAP_CAUSE_RADIO_NETWORK, - 30); + NGAP_CAUSE_RADIO_NETWORK_RADIO_CONNECTION_WITH_UE_LOST); } // Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G @@ -4113,7 +4135,7 @@ void *rrc_gnb_task(void *args_p) { NR_RRC_DCCH_DATA_IND(msg_p).rnti, msg_p->ittiMsgHeader.lte_time.frame, msg_p->ittiMsgHeader.lte_time.slot); - LOG_I(NR_RRC,"Decoding DCCH : ue %d, inst %ld, ctxt %p, size %d\n", + LOG_D(NR_RRC,"Decoding DCCH : ue %d, inst %ld, ctxt %p, size %d\n", ctxt.rnti, instance, &ctxt, diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 69d3e4a52b..46954b5734 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -297,7 +297,7 @@ void nr_rrc_pdcp_config_security( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, - const uint8_t send_security_mode_command + const uint8_t enable_ciphering ) //------------------------------------------------------------------------------ { @@ -309,40 +309,20 @@ nr_rrc_pdcp_config_security( uint8_t *k_kdf = NULL; static int print_keys= 1; -#ifndef PHYSIM + /* Derive the keys from kgnb */ if (SRB_configList != NULL) { - k_kdf = NULL; nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, ue_context_pP->ue_context.kgnb, - &k_kdf); - /* kUPenc: last 128 bits of key derivation function which returns 256 bits */ - kUPenc = malloc(16); - if (kUPenc == NULL) exit(1); - memcpy(kUPenc, k_kdf+16, 16); - free(k_kdf); + &kUPenc); } - k_kdf = NULL; nr_derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, ue_context_pP->ue_context.kgnb, - &k_kdf); - /* kRRCenc: last 128 bits of key derivation function which returns 256 bits */ - kRRCenc = malloc(16); - if (kRRCenc == NULL) exit(1); - memcpy(kRRCenc, k_kdf+16, 16); - free(k_kdf); - - k_kdf = NULL; + &kRRCenc); nr_derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, ue_context_pP->ue_context.kgnb, - &k_kdf); - /* kRRCint: last 128 bits of key derivation function which returns 256 bits */ - kRRCint = malloc(16); - if (kRRCint == NULL) exit(1); - memcpy(kRRCint, k_kdf+16, 16); - free(k_kdf); -#endif + &kRRCint); if (!IS_SOFTMODEM_IQPLAYER) { SET_LOG_DUMP(DEBUG_SECURITY) ; } @@ -362,10 +342,11 @@ nr_rrc_pdcp_config_security( NULL, /* pdcp_pP not used anymore in NR */ DCCH, DCCH+2, - (send_security_mode_command == TRUE) ? - 0 | (ue_context_pP->ue_context.integrity_algorithm << 4) : - (ue_context_pP->ue_context.ciphering_algorithm ) | - (ue_context_pP->ue_context.integrity_algorithm << 4), + enable_ciphering ? + ue_context_pP->ue_context.ciphering_algorithm + | (ue_context_pP->ue_context.integrity_algorithm << 4) + : 0 + | (ue_context_pP->ue_context.integrity_algorithm << 4), kRRCenc, kRRCint, kUPenc); @@ -599,25 +580,10 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( ue_context_p, NGAP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key); - uint8_t send_security_mode_command = TRUE; + /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ + nr_rrc_pdcp_config_security(&ctxt, ue_context_p, 0); - nr_rrc_pdcp_config_security( - &ctxt, - ue_context_p, - send_security_mode_command); - - if (send_security_mode_command) { - rrc_gNB_generate_SecurityModeCommand (&ctxt, ue_context_p); - send_security_mode_command = FALSE; - - nr_rrc_pdcp_config_security( - &ctxt, - ue_context_p, - send_security_mode_command); - } else { - /* rrc_gNB_generate_UECapabilityEnquiry */ - rrc_gNB_generate_UECapabilityEnquiry(&ctxt, ue_context_p); - } + rrc_gNB_generate_SecurityModeCommand (&ctxt, ue_context_p); // in case, send the S1SP initial context response if it is not sent with the attach complete message if (ue_context_p->ue_context.StatusRrc == NR_RRC_RECONFIGURED) { @@ -685,43 +651,76 @@ rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP( itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); } -static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering(uint16_t algorithms) { +static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering( + const protocol_ctxt_t *const ctxt_pP, + uint16_t algorithms) +{ + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + int i; + /* preset nea0 as fallback */ + int ret = 0; - return NR_CipheringAlgorithm_nea0; - - - if (algorithms & NGAP_ENCRYPTION_NEA3_MASK) { - return NR_CipheringAlgorithm_nea3; + /* Select ciphering algorithm based on gNB configuration file and + * UE's supported algorithms. + * We take the first from the list that is supported by the UE. + * The ordering of the list comes from the configuration file. + */ + for (i = 0; i < rrc->security.ciphering_algorithms_count; i++) { + int nea_mask[4] = { + 0, + NGAP_ENCRYPTION_NEA1_MASK, + NGAP_ENCRYPTION_NEA2_MASK, + NGAP_ENCRYPTION_NEA3_MASK + }; + if (rrc->security.ciphering_algorithms[i] == 0) { + /* nea0 */ + break; + } + if (algorithms & nea_mask[rrc->security.ciphering_algorithms[i]]) { + ret = rrc->security.ciphering_algorithms[i]; + break; + } } - if (algorithms & NGAP_ENCRYPTION_NEA2_MASK) { - return NR_CipheringAlgorithm_nea2; - } - - if (algorithms & NGAP_ENCRYPTION_NEA1_MASK) { - return NR_CipheringAlgorithm_nea1; - } + LOG_I(RRC, "selecting ciphering algorithm %d\n", ret); + return ret; } -static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(uint16_t algorithms) { - - //only NIA2 supported for now - return NR_IntegrityProtAlgorithm_nia2; +static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity( + const protocol_ctxt_t *const ctxt_pP, + uint16_t algorithms) +{ + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + int i; + /* preset nia0 as fallback */ + int ret = 0; - if (algorithms & NGAP_INTEGRITY_NIA3_MASK) { - return NR_IntegrityProtAlgorithm_nia3; + /* Select integrity algorithm based on gNB configuration file and + * UE's supported algorithms. + * We take the first from the list that is supported by the UE. + * The ordering of the list comes from the configuration file. + */ + for (i = 0; i < rrc->security.integrity_algorithms_count; i++) { + int nia_mask[4] = { + 0, + NGAP_INTEGRITY_NIA1_MASK, + NGAP_INTEGRITY_NIA2_MASK, + NGAP_INTEGRITY_NIA3_MASK + }; + if (rrc->security.integrity_algorithms[i] == 0) { + /* nia0 */ + break; + } + if (algorithms & nia_mask[rrc->security.integrity_algorithms[i]]) { + ret = rrc->security.integrity_algorithms[i]; + break; + } } - if (algorithms & NGAP_INTEGRITY_NIA2_MASK) { - return NR_IntegrityProtAlgorithm_nia2; - } + LOG_I(RRC, "selecting integrity algorithm %d\n", ret); - if (algorithms & NGAP_INTEGRITY_NIA1_MASK) { - return NR_IntegrityProtAlgorithm_nia1; - } - - return NR_IntegrityProtAlgorithm_nia0; + return ret; } int @@ -744,14 +743,14 @@ rrc_gNB_process_security( ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms, ue_context_pP->ue_context.integrity_algorithm); /* Select relevant algorithms */ - cipheringAlgorithm = rrc_gNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms); + cipheringAlgorithm = rrc_gNB_select_ciphering(ctxt_pP, ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms); if (ue_context_pP->ue_context.ciphering_algorithm != cipheringAlgorithm) { ue_context_pP->ue_context.ciphering_algorithm = cipheringAlgorithm; changed = TRUE; } - integrityProtAlgorithm = rrc_gNB_select_integrity (ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms); + integrityProtAlgorithm = rrc_gNB_select_integrity(ctxt_pP, ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms); if (ue_context_pP->ue_context.integrity_algorithm != integrityProtAlgorithm) { ue_context_pP->ue_context.integrity_algorithm = integrityProtAlgorithm; diff --git a/openair2/RRC/NR/rrc_gNB_UE_context.c b/openair2/RRC/NR/rrc_gNB_UE_context.c index eb7559f69d..ad8bd01470 100644 --- a/openair2/RRC/NR/rrc_gNB_UE_context.c +++ b/openair2/RRC/NR/rrc_gNB_UE_context.c @@ -139,7 +139,7 @@ rrc_gNB_allocate_new_UE_context( new_p->ue_context.modify_e_rab[i].xid = -1; } - LOG_I(NR_RRC,"Returning new UE context at %p\n",new_p); + LOG_D(NR_RRC,"Returning new UE context at %p\n",new_p); return(new_p); } diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 167f85ba48..f9fce48f41 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -52,9 +52,7 @@ extern boolean_t nr_rrc_pdcp_config_asn1_req( uint8_t *const kRRCint, uint8_t *const kUPenc, uint8_t *const kUPint - #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 - #endif ,rb_id_t *const defaultDRB, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); @@ -142,6 +140,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; protocol_ctxt_t ctxt={0}; unsigned char *kUPenc = NULL; + unsigned char *kUPint = NULL; int i; // NR RRCReconfiguration AssertFatal(rrc->Nb_ue < MAX_NR_RRC_UE_CONTEXTS,"cannot add another UE\n"); @@ -214,15 +213,12 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ LOG_I(RRC, "selecting integrity algorithm %d\n", ue_context_p->ue_context.integrity_algorithm); /* derive UP security key */ - unsigned char *kUPenc_kdf; nr_derive_key_up_enc(ue_context_p->ue_context.ciphering_algorithm, ue_context_p->ue_context.kgnb, - &kUPenc_kdf); - /* kUPenc: last 128 bits of key derivation function which returns 256 bits */ - kUPenc = malloc(16); - if (kUPenc == NULL) exit(1); - memcpy(kUPenc, kUPenc_kdf+16, 16); - free(kUPenc_kdf); + &kUPenc); + nr_derive_key_up_int(ue_context_p->ue_context.integrity_algorithm, + ue_context_p->ue_context.kgnb, + &kUPint); e_NR_CipheringAlgorithm cipher_algo; switch (ue_context_p->ue_context.ciphering_algorithm) { @@ -355,6 +351,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ rrc->carrier.pusch_AntennaPorts, rrc->carrier.sib1_tda, rrc->carrier.servingcellconfigcommon, + &rrc->carrier.mib, 1, // add_ue flag ue_context_p->ue_id_rnti, ue_context_p->ue_context.secondaryCellGroup); @@ -365,6 +362,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ rrc->carrier.pusch_AntennaPorts, rrc->carrier.sib1_tda, NULL, + NULL, 1, // add_ue flag ue_context_p->ue_id_rnti, ue_context_p->ue_context.secondaryCellGroup); @@ -387,7 +385,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ NULL, /* kRRCenc - unused */ NULL, /* kRRCint - unused */ kUPenc, /* kUPenc */ - NULL, /* kUPint - unused */ + kUPint, /* kUPint */ NULL, NULL, ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index ad39b1b5e0..6892599ec0 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -187,9 +187,7 @@ extern boolean_t nr_rrc_pdcp_config_asn1_req( uint8_t *const kRRCint, uint8_t *const kUPenc, uint8_t *const kUPint - #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 - #endif ,rb_id_t *const defaultDRB, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); @@ -237,8 +235,9 @@ int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, int8_t nr_rrc_ue_process_RadioBearerConfig(NR_RadioBearerConfig_t *RadioBearerConfig){ - - xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)RadioBearerConfig); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); + } // Configure PDCP return 0; @@ -268,7 +267,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf, rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->size, 0, 0); - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); + } if(NR_UE_rrc_inst[module_id].cell_group_config == NULL){ // first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time. @@ -1257,7 +1258,10 @@ nr_rrc_ue_process_masterCellGroup( (void **)&cellGroupConfig, (uint8_t *)masterCellGroup->buf, masterCellGroup->size, 0, 0); - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); + } if( cellGroupConfig->spCellConfig != NULL && cellGroupConfig->spCellConfig->reconfigurationWithSync != NULL){ //TODO (perform Reconfiguration with sync according to 5.3.5.5.2) @@ -1415,11 +1419,11 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB &asn_DEF_NR_DL_CCCH_Message, (void **)&dl_ccch_msg, (uint8_t *)Srb_info->Rx_buffer.Payload, - 100,0,0); + Srb_info->Rx_buffer.payload_size,0,0); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { +// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout,&asn_DEF_NR_DL_CCCH_Message,(void *)dl_ccch_msg); - } +// } if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%zu bytes)\n",ctxt_pP->module_id,ctxt_pP->frame,dec_rval.consumed); @@ -1657,45 +1661,40 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB uint8_t *kRRCenc = NULL; uint8_t *kUPenc = NULL; uint8_t *kRRCint = NULL; - pdcp_t *pdcp_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES); - h_rc = hashtable_get(pdcp_coll_p, key, (void **) &pdcp_p); + nr_derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, + &kUPenc); + nr_derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, + &kRRCenc); + nr_derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, + &kRRCint); + LOG_I(NR_RRC, "driving kRRCenc, kRRCint and kUPenc from KgNB=" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x\n", + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[0], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[1], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[2], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[3], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[4], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[5], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[6], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[7], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[8], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[9], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[10], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[11], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[12], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[13], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[14], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[15], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[16], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[17], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[18], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[19], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[20], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[21], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[22], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[23], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[24], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[25], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[26], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[27], + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[28], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[29], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[30], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[31]); - if (h_rc == HASH_TABLE_OK) { - LOG_D(NR_RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %ld\n", key); - LOG_D(NR_RRC, "driving kRRCenc, kRRCint and kUPenc from KgNB=" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x" - "%02x%02x%02x%02x\n", - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[0], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[1], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[2], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[3], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[4], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[5], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[6], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[7], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[8], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[9], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[10], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[11], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[12], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[13], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[14], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[15], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[16], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[17], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[18], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[19], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[20], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[21], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[22], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[23], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[24], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[25], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[26], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[27], - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[28], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[29], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[30], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[31]); - derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm,NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCenc); - derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm,NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint); - derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm,NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPenc); - - if (securityMode != 0xff) { - pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm - | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), - kRRCenc, kRRCint, kUPenc); - } else { - LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode); - } + if (securityMode != 0xff) { + pdcp_config_set_security(ctxt_pP, NULL, DCCH, DCCH+2, + NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm + | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + kRRCenc, kRRCint, kUPenc); } else { - LOG_I(NR_RRC, "Could not get PDCP instance where key=0x%ld\n", key); + LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode); } if (securityModeCommand->criticalExtensions.present == NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand) { @@ -2042,10 +2041,11 @@ nr_rrc_ue_establish_srb2( uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; - derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCenc); - derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint); + nr_derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCenc); + nr_derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint); + // Refresh SRBs nr_rrc_pdcp_config_asn1_req(ctxt_pP, radioBearerConfig->srb_ToAddModList, @@ -2086,6 +2086,7 @@ nr_rrc_ue_establish_srb2( LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 gNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id); + nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,gNB_index,1,true); //todo handle mac_LogicalChannelConfig // rrc_mac_config_req_ue } } else { @@ -2101,6 +2102,7 @@ nr_rrc_ue_establish_srb2( LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 gNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id); + nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,gNB_index,2,true); //todo handle mac_LogicalChannelConfig // rrc_mac_config_req_ue } } // srb2 @@ -2121,14 +2123,34 @@ nr_rrc_ue_establish_srb2( memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1], radioBearerConfig->drb_ToAddModList->list.array[cnt], sizeof(NR_DRB_ToAddMod_t)); } else { - LOG_D(NR_RRC, "Adding DRB %ld %p\n", DRB_id-1, radioBearerConfig->drb_ToAddModList->list.array[cnt]); + //LOG_D(NR_RRC, "Adding DRB %ld %p\n", DRB_id-1, radioBearerConfig->drb_ToAddModList->list.array[cnt]); NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1] = radioBearerConfig->drb_ToAddModList->list.array[cnt]; + int j; + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list = NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList; + if (rlc_bearer2add_list != NULL) { + 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(DRB_id == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.drb_Identity){ + LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB lcid %ld gNB %d) --->][MAC_UE][MOD %02d][]\n", + ctxt_pP->frame, ctxt_pP->module_id, rlc_bearer2add_list->list.array[j]->logicalChannelIdentity, 0, ctxt_pP->module_id); + nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,0,rlc_bearer2add_list->list.array[j]->logicalChannelIdentity,true); //todo handle mac_LogicalChannelConfig + } + } + } + } + } } } uint8_t *kUPenc = NULL; - derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPenc); + uint8_t *kUPint = NULL; + + nr_derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPenc); + nr_derive_key_up_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPint); + MSC_LOG_TX_MESSAGE( MSC_RRC_UE, MSC_PDCP_UE, @@ -2149,7 +2171,7 @@ nr_rrc_ue_establish_srb2( NULL, NULL, kUPenc, - NULL, + kUPint, NULL, NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); @@ -2170,6 +2192,15 @@ nr_rrc_ue_establish_srb2( } } + if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList != NULL) { + for (i = 0; i < NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList->list.count; i++) { + NR_LogicalChannelIdentity_t lcid = *NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList->list.array[i]; + LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (RB lcid %ld gNB %d release) --->][MAC_UE][MOD %02d][]\n", + ctxt_pP->frame, ctxt_pP->module_id, lcid, 0, ctxt_pP->module_id); + nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,0,lcid,false); //todo handle mac_LogicalChannelConfig + } + } + NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State = NR_RRC_CONNECTED; LOG_I(NR_RRC,"[UE %d] State = NR_RRC_CONNECTED (gNB %d)\n", ctxt_pP->module_id, gNB_index); } @@ -2306,9 +2337,9 @@ nr_rrc_ue_establish_srb2( return -1; } - // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message,(void *)dl_dcch_msg); - // } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message,(void *)dl_dcch_msg); + } if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { switch (dl_dcch_msg->message.choice.c1->present) { @@ -2482,6 +2513,28 @@ nr_rrc_ue_establish_srb2( NR_RRC_DCCH_DATA_IND (msg_p).gNB_index); break; + case NAS_KENB_REFRESH_REQ: + memcpy((void *)NR_UE_rrc_inst[ue_mod_id].kgnb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(NR_UE_rrc_inst[ue_mod_id].kgnb)); + LOG_D(RRC, "[UE %d] Received %s: refreshed RRC::KgNB = " + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x\n", + ue_mod_id, ITTI_MSG_NAME (msg_p), + NR_UE_rrc_inst[ue_mod_id].kgnb[0], NR_UE_rrc_inst[ue_mod_id].kgnb[1], NR_UE_rrc_inst[ue_mod_id].kgnb[2], NR_UE_rrc_inst[ue_mod_id].kgnb[3], + NR_UE_rrc_inst[ue_mod_id].kgnb[4], NR_UE_rrc_inst[ue_mod_id].kgnb[5], NR_UE_rrc_inst[ue_mod_id].kgnb[6], NR_UE_rrc_inst[ue_mod_id].kgnb[7], + NR_UE_rrc_inst[ue_mod_id].kgnb[8], NR_UE_rrc_inst[ue_mod_id].kgnb[9], NR_UE_rrc_inst[ue_mod_id].kgnb[10], NR_UE_rrc_inst[ue_mod_id].kgnb[11], + NR_UE_rrc_inst[ue_mod_id].kgnb[12], NR_UE_rrc_inst[ue_mod_id].kgnb[13], NR_UE_rrc_inst[ue_mod_id].kgnb[14], NR_UE_rrc_inst[ue_mod_id].kgnb[15], + NR_UE_rrc_inst[ue_mod_id].kgnb[16], NR_UE_rrc_inst[ue_mod_id].kgnb[17], NR_UE_rrc_inst[ue_mod_id].kgnb[18], NR_UE_rrc_inst[ue_mod_id].kgnb[19], + NR_UE_rrc_inst[ue_mod_id].kgnb[20], NR_UE_rrc_inst[ue_mod_id].kgnb[21], NR_UE_rrc_inst[ue_mod_id].kgnb[22], NR_UE_rrc_inst[ue_mod_id].kgnb[23], + NR_UE_rrc_inst[ue_mod_id].kgnb[24], NR_UE_rrc_inst[ue_mod_id].kgnb[25], NR_UE_rrc_inst[ue_mod_id].kgnb[26], NR_UE_rrc_inst[ue_mod_id].kgnb[27], + NR_UE_rrc_inst[ue_mod_id].kgnb[28], NR_UE_rrc_inst[ue_mod_id].kgnb[29], NR_UE_rrc_inst[ue_mod_id].kgnb[30], NR_UE_rrc_inst[ue_mod_id].kgnb[31]); + break; + case NAS_UPLINK_DATA_REQ: { uint32_t length; uint8_t *buffer; diff --git a/openair2/SDAP/nr_sdap/nr_sdap_gnb.c b/openair2/SDAP/nr_sdap/nr_sdap_gnb.c new file mode 100644 index 0000000000..5f0a2640e9 --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap_gnb.c @@ -0,0 +1,87 @@ +/* + * 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 "nr_sdap_gnb.h" +#include + +boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id + ) { + if(sdu_buffer == NULL) { + LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - NULL sdu_buffer \n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + + if(sdu_buffer_size == 0) { + LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - NULL or 0 sdu_buffer_size \n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + + uint8_t *sdap_buf = (uint8_t *)malloc(sdu_buffer_size+SDAP_HDR_LENGTH); + nr_sdap_dl_hdr_t sdap_hdr; + sdap_hdr.RDI = 0; // SDAP_Hardcoded - + sdap_hdr.RQI = 0; // SDAP_Hardcoded - Should get this info from DL_PDU_SESSION_INFORMATION + sdap_hdr.QFI = 1; // SDAP_Hardcoded - Should get this info from DL_PDU_SESSION_INFORMATION + memcpy(&sdap_buf[0], &sdap_hdr, 1); + memcpy(&sdap_buf[1], sdu_buffer, sdu_buffer_size); + rb_id_t sdap_drb_id = rb_id; // SDAP_Hardcoded - Should get this info from QFI to DRB mapping table + boolean_t ret = pdcp_data_req(ctxt_p, + srb_flag, + sdap_drb_id, + mui, + confirm, + sdu_buffer_size+1, + sdap_buf, + pt_mode, + sourceL2Id, + destinationL2Id); + + if(!ret) { + LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - PDCP DL refused PDU\n", __FILE__, __LINE__, __FUNCTION__); + free(sdap_buf); + return 0; + } + + free(sdap_buf); + return 1; +} + +void sdap_gnb_ul_header_handler(char sdap_gnb_ul_hdr) { + nr_sdap_ul_hdr_t *sdap_hdr_ul = (nr_sdap_ul_hdr_t *)&sdap_gnb_ul_hdr; + + switch (sdap_hdr_ul->DC) { + case SDAP_HDR_UL_DATA_PDU: + LOG_I(PDCP, "%s:%d:%s: SDAP Layer gNB - UL Received SDAP Data PDU\n", __FILE__, __LINE__, __FUNCTION__); + break; + + case SDAP_HDR_UL_CTRL_PDU: + LOG_I(PDCP, "%s:%d:%s: SDAP Layer gNB - Received SDAP Control PDU\n", __FILE__, __LINE__, __FUNCTION__); + break; + } +} \ No newline at end of file diff --git a/openair2/SDAP/nr_sdap/nr_sdap_gnb.h b/openair2/SDAP/nr_sdap/nr_sdap_gnb.h new file mode 100644 index 0000000000..243aa89010 --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap_gnb.h @@ -0,0 +1,61 @@ +/* + * 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 + */ + +#ifndef _NR_SDAP_GNB_ +#define _NR_SDAP_GNB_ + +#include "openair2/COMMON/platform_types.h" +#include "common/utils/LOG/log.h" + +#define SDAP_BITMASK_DC (0x80) +#define SDAP_BITMASK_R (0x40) +#define SDAP_BITMASK_QFI (0x3F) +#define SDAP_HDR_UL_DATA_PDU (1) +#define SDAP_HDR_UL_CTRL_PDU (0) +#define SDAP_HDR_LENGTH (1) + +typedef struct nr_sdap_dl_hdr_s { + uint8_t QFI:6; + uint8_t RQI:1; + uint8_t RDI:1; +} __attribute__((packed)) nr_sdap_dl_hdr_t; + +typedef struct nr_sdap_ul_hdr_s { + uint8_t QFI:6; + uint8_t R:1; + uint8_t DC:1; +} __attribute__((packed)) nr_sdap_ul_hdr_t; + +boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id + ); + +void sdap_gnb_ul_header_handler(char sdap_gnb_ul_hdr); + +#endif \ No newline at end of file diff --git a/openair2/UTIL/OSA/osa_key_deriver.c b/openair2/UTIL/OSA/osa_key_deriver.c index 159ee7f159..c02b999490 100644 --- a/openair2/UTIL/OSA/osa_key_deriver.c +++ b/openair2/UTIL/OSA/osa_key_deriver.c @@ -121,6 +121,8 @@ int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, string[6] = 0x01; kdf(string, 7, key, 32, out, 32); + // in NR, we use the last 16 bytes, ignoring the first 16 ones + memcpy(*out, *out+16, 16); return 0; } diff --git a/openair3/NAS/COMMON/API/NETWORK/as_message.c b/openair3/NAS/COMMON/API/NETWORK/as_message.c index fd3f15cb4c..4a2da21594 100644 --- a/openair3/NAS/COMMON/API/NETWORK/as_message.c +++ b/openair3/NAS/COMMON/API/NETWORK/as_message.c @@ -81,7 +81,12 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length) LOG_FUNC_IN; int bytes; - Byte_t** data = NULL; + /* pointers to msg fields possibly not aligned because msg points to a packed structure + * Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and + * gcc, from v9, now warns about it. fix these warnings by removing the indirection on data + * (in fact i don't understand this code data seems to be useless...) + */ + Byte_t *data = NULL; /* Get the message type */ msg->msgID = *(uint16_t*)(buffer); @@ -91,49 +96,49 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length) case AS_NAS_ESTABLISH_REQ: /* NAS signalling connection establish request */ bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*); - data = &msg->msg.nas_establish_req.initialNasMsg.data; + data = msg->msg.nas_establish_req.initialNasMsg.data; break; case AS_NAS_ESTABLISH_IND: /* NAS signalling connection establishment indication */ bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*); - data = &msg->msg.nas_establish_ind.initialNasMsg.data; + data = msg->msg.nas_establish_ind.initialNasMsg.data; break; case AS_NAS_ESTABLISH_RSP: /* NAS signalling connection establishment response */ bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*); - data = &msg->msg.nas_establish_rsp.nasMsg.data; + data = msg->msg.nas_establish_rsp.nasMsg.data; break; case AS_NAS_ESTABLISH_CNF: /* NAS signalling connection establishment confirm */ bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*); - data = &msg->msg.nas_establish_cnf.nasMsg.data; + data = msg->msg.nas_establish_cnf.nasMsg.data; break; case AS_UL_INFO_TRANSFER_REQ: /* Uplink L3 data transfer request */ bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*); - data = &msg->msg.ul_info_transfer_req.nasMsg.data; + data = msg->msg.ul_info_transfer_req.nasMsg.data; break; case AS_UL_INFO_TRANSFER_IND: /* Uplink L3 data transfer indication */ bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*); - data = &msg->msg.ul_info_transfer_ind.nasMsg.data; + data = msg->msg.ul_info_transfer_ind.nasMsg.data; break; case AS_DL_INFO_TRANSFER_REQ: /* Downlink L3 data transfer request */ bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*); - data = &msg->msg.dl_info_transfer_req.nasMsg.data; + data = msg->msg.dl_info_transfer_req.nasMsg.data; break; case AS_DL_INFO_TRANSFER_IND: /* Downlink L3 data transfer indication */ bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*); - data = &msg->msg.dl_info_transfer_ind.nasMsg.data; + data = msg->msg.dl_info_transfer_ind.nasMsg.data; break; case AS_BROADCAST_INFO_IND: @@ -166,7 +171,8 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length) if (bytes > 0) { if (data) { /* Set the pointer to dedicated NAS information */ - *data = (Byte_t*)(buffer + bytes); + /* wasn't data already computed above for specific cases here we override ?? */ + data = (Byte_t *)buffer + bytes; } /* Decode the message */ @@ -201,8 +207,10 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) LOG_FUNC_IN; int bytes = sizeof(msg->msgID); - as_nas_info_t* nas_msg = NULL; - + as_nas_info_t nas_msg; + Byte_t *dataptr=NULL; + uint32_t len=0; + switch (msg->msgID) { case AS_BROADCAST_INFO_IND: /* Broadcast information */ @@ -237,25 +245,30 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) case AS_NAS_ESTABLISH_REQ: /* NAS signalling connection establish request */ bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.nas_establish_req.initialNasMsg; + nas_msg = msg->msg.nas_establish_req.initialNasMsg; break; case AS_NAS_ESTABLISH_IND: /* NAS signalling connection establish indication */ bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.nas_establish_ind.initialNasMsg; + nas_msg = msg->msg.nas_establish_ind.initialNasMsg; + dataptr=(Byte_t *)&(msg->msg.nas_establish_ind.initialNasMsg.data); + len=msg->msg.nas_establish_ind.initialNasMsg.length; break; case AS_NAS_ESTABLISH_RSP: /* NAS signalling connection establish response */ bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.nas_establish_rsp.nasMsg; + nas_msg = msg->msg.nas_establish_rsp.nasMsg; + break; case AS_NAS_ESTABLISH_CNF: /* NAS signalling connection establish confirm */ bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.nas_establish_cnf.nasMsg; + nas_msg = msg->msg.nas_establish_cnf.nasMsg; + dataptr=(Byte_t *)&(msg->msg.nas_establish_cnf.nasMsg.data); + len=msg->msg.nas_establish_ind.initialNasMsg.length; break; case AS_NAS_RELEASE_REQ: @@ -271,7 +284,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) case AS_UL_INFO_TRANSFER_REQ: /* Uplink L3 data transfer request */ bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.ul_info_transfer_req.nasMsg; + nas_msg = msg->msg.ul_info_transfer_req.nasMsg; break; case AS_UL_INFO_TRANSFER_CNF: @@ -282,13 +295,13 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) case AS_UL_INFO_TRANSFER_IND: /* Uplink L3 data transfer indication */ bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.ul_info_transfer_ind.nasMsg; + nas_msg = msg->msg.ul_info_transfer_ind.nasMsg; break; case AS_DL_INFO_TRANSFER_REQ: /* Downlink L3 data transfer */ bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.dl_info_transfer_req.nasMsg; + nas_msg = msg->msg.dl_info_transfer_req.nasMsg; break; case AS_DL_INFO_TRANSFER_CNF: @@ -299,7 +312,8 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) case AS_DL_INFO_TRANSFER_IND: /* Downlink L3 data transfer indication */ bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*); - nas_msg = &msg->msg.dl_info_transfer_ind.nasMsg; + nas_msg = msg->msg.dl_info_transfer_ind.nasMsg; + break; case AS_RAB_ESTABLISH_REQ: @@ -343,14 +357,14 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) /* Encode the AS message */ memcpy(buffer, (unsigned char*)msg, bytes); - if ( nas_msg && (nas_msg->length > 0) ) { + if ( (dataptr!=NULL) && (len > 0) ) { /* Copy the NAS message */ - memcpy(buffer + bytes, nas_msg->data, nas_msg->length); - bytes += nas_msg->length; + memcpy(buffer + bytes, nas_msg.data, nas_msg.length); + bytes += len; /* Release NAS message memory */ - free(nas_msg->data); - nas_msg->length = 0; - nas_msg->data = NULL; + free(nas_msg.data); + len=0; + dataptr = NULL; } LOG_FUNC_RETURN (bytes); diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index e8596e66e9..2628c5b0b2 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -48,6 +48,8 @@ uint8_t *registration_request_buf; uint32_t registration_request_len; extern char *baseNetAddress; +extern uint16_t NB_UE_INST; +static ue_sa_security_key_t ** ue_security_key; static int nas_protected_security_header_encode( char *buffer, @@ -252,6 +254,108 @@ void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t knas_int[i] = out[16 + i]; } +void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){ + /* Compute the KDF input parameter + * S = FC(0x6E) || UL NAS Count || 0x00 0x04 || 0x01 || 0x00 0x01 + */ + uint8_t input[32]; + // uint16_t length = 4; + // int offset = 0; + uint8_t out[32] = { 0 }; + + LOG_TRACE(INFO, "%s with count= %d", __FUNCTION__, count); + memset(input, 0, 32); + input[0] = 0x6E; + // P0 + input[1] = count >> 24; + input[2] = (uint8_t)(count >> 16); + input[3] = (uint8_t)(count >> 8); + input[4] = (uint8_t)count; + // L0 + input[5] = 0; + input[6] = 4; + // P1 + input[7] = 0x01; + // L1 + input[8] = 0; + input[9] = 1; + + kdf(kamf, 32, input, 10, out, 32); + for (int i = 0; i < 32; i++) + kgnb[i] = out[i]; + printf("kgnb : "); + for(int pp=0;pp<32;pp++) + printf("%02x ",kgnb[pp]); + printf("\n"); +} + +void derive_ue_keys(int Mod_id, uint8_t *buf, uicc_t *uicc) { + uint8_t ak[6]; + uint8_t sqn[6]; + + AssertFatal (Mod_id < NB_UE_INST, "Failed, Mod_id %d is over NB_UE_INST!\n", Mod_id); + if(ue_security_key[Mod_id]){ + // clear old key + memset(ue_security_key[Mod_id],0,sizeof(ue_sa_security_key_t)); + }else{ + // Allocate new memory + ue_security_key[Mod_id]=(ue_sa_security_key_t *)calloc(1,sizeof(ue_sa_security_key_t)); + } + uint8_t *kausf = ue_security_key[Mod_id]->kausf; + uint8_t *kseaf = ue_security_key[Mod_id]->kseaf; + uint8_t *kamf = ue_security_key[Mod_id]->kamf; + uint8_t *knas_int = ue_security_key[Mod_id]->knas_int; + uint8_t *output = ue_security_key[Mod_id]->res; + uint8_t *rand = ue_security_key[Mod_id]->rand; + uint8_t *kgnb = ue_security_key[Mod_id]->kgnb; + + // get RAND for authentication request + for(int index = 0; index < 16;index++){ + rand[index] = buf[8+index]; + } + + uint8_t resTemp[16]; + uint8_t ck[16], ik[16]; + f2345(uicc->key, rand, resTemp, ck, ik, ak, uicc->opc); + + transferRES(ck, ik, resTemp, rand, output, uicc); + + for(int index = 0; index < 6; index++){ + sqn[index] = buf[26+index]; + } + + derive_kausf(ck, ik, sqn, kausf, uicc); + derive_kseaf(kausf, kseaf, uicc); + derive_kamf(kseaf, kamf, 0x0000, uicc); + derive_knas(0x02, 2, kamf, knas_int); + derive_kgnb(kamf,0,kgnb); + + printf("kausf:"); + for(int i = 0; i < 32; i++){ + printf("%x ", kausf[i]); + } + printf("\n"); + + printf("kseaf:"); + for(int i = 0; i < 32; i++){ + printf("%x ", kseaf[i]); + } + + printf("\n"); + + printf("kamf:"); + for(int i = 0; i < 32; i++){ + printf("%x ", kamf[i]); + } + printf("\n"); + + printf("knas_int:\n"); + for(int i = 0; i < 16; i++){ + printf("%x ", knas_int[i]); + } + printf("\n"); +} + void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id) { int size = sizeof(mm_msg_header_t); fgs_nas_message_t nas_msg={0}; @@ -374,69 +478,13 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype } -OctetString knas_int; -static void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf, uicc_t *uicc){ +static void generateAuthenticationResp(int Mod_id,as_nas_info_t *initialNasMsg, uint8_t *buf, uicc_t *uicc){ - uint8_t ak[6]; - - uint8_t kausf[32]; - uint8_t sqn[6]; - uint8_t kseaf[32]; - uint8_t kamf[32]; + derive_ue_keys(Mod_id,buf,uicc); OctetString res; - - // get RAND for authentication request - unsigned char rand[16]; - for(int index = 0; index < 16;index++){ - rand[index] = buf[8+index]; - } - - uint8_t resTemp[16]; - uint8_t ck[16], ik[16], output[16]; - f2345(uicc->key, rand, resTemp, ck, ik, ak, uicc->opc); - - transferRES(ck, ik, resTemp, rand, output, uicc); - - // get knas_int - knas_int.length = 16; - knas_int.value = malloc(knas_int.length); - for(int index = 0; index < 6; index++){ - sqn[index] = buf[26+index]; - } - - derive_kausf(ck, ik, sqn, kausf, uicc); - derive_kseaf(kausf, kseaf, uicc); - derive_kamf(kseaf, kamf, 0x0000, uicc); - derive_knas(0x02, 2, kamf, knas_int.value); - - printf("kausf:"); - for(int i = 0; i < 32; i++){ - printf("%x ", kausf[i]); - } - printf("\n"); - - printf("kseaf:"); - for(int i = 0; i < 32; i++){ - printf("%x ", kseaf[i]); - } - - printf("\n"); - - printf("kamf:"); - for(int i = 0; i < 32; i++){ - printf("%x ", kamf[i]); - } - printf("\n"); - - printf("knas_int:\n"); - for(int i = 0; i < 16; i++){ - printf("%x ", knas_int.value[i]); - } - printf("\n"); - - // set res res.length = 16; - res.value = output; + res.value = calloc(1,16); + memcpy(res.value,ue_security_key[Mod_id]->res,16); int size = sizeof(mm_msg_header_t); fgs_nas_message_t nas_msg; @@ -466,7 +514,14 @@ static void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *bu initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size); } -static void generateSecurityModeComplete(as_nas_info_t *initialNasMsg) +int nas_itti_kgnb_refresh_req(const uint8_t kgnb[32], int instance) { + MessageDef *message_p; + message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_KENB_REFRESH_REQ); + memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kgnb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb)); + return itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); +} + +static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg) { int size = sizeof(mm_msg_header_t); fgs_nas_message_t nas_msg; @@ -513,7 +568,7 @@ static void generateSecurityModeComplete(as_nas_info_t *initialNasMsg) initialNasMsg->length = security_header_len + mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data+security_header_len), size-security_header_len); - stream_cipher.key = knas_int.value; + stream_cipher.key = ue_security_key[Mod_id]->knas_int; stream_cipher.key_length = 16; stream_cipher.count = 0; stream_cipher.bearer = 1; @@ -533,7 +588,7 @@ static void generateSecurityModeComplete(as_nas_info_t *initialNasMsg) } } -static void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) { +static void generateRegistrationComplete(int Mod_id, as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) { //wait send RRCReconfigurationComplete and InitialContextSetupResponse sleep(1); int length = 0; @@ -593,7 +648,7 @@ static void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransp } initialNasMsg->length = length; - stream_cipher.key = knas_int.value; + stream_cipher.key = ue_security_key[Mod_id]->knas_int; stream_cipher.key_length = 16; stream_cipher.count = 1; stream_cipher.bearer = 1; @@ -626,7 +681,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff } } -static void generatePduSessionEstablishRequest(uicc_t * uicc, as_nas_info_t *initialNasMsg){ +static void generatePduSessionEstablishRequest(int Mod_id, uicc_t * uicc, as_nas_info_t *initialNasMsg){ //wait send RegistrationComplete usleep(100*150); int size = 0; @@ -700,7 +755,7 @@ static void generatePduSessionEstablishRequest(uicc_t * uicc, as_nas_info_t *ini initialNasMsg->length = security_header_len + mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data+security_header_len), size-security_header_len); - stream_cipher.key = knas_int.value; + stream_cipher.key = ue_security_key[Mod_id]->knas_int; stream_cipher.key_length = 16; stream_cipher.count = 0; stream_cipher.bearer = 1; @@ -754,6 +809,8 @@ void *nas_nrue_task(void *args_p) uint8_t msg_type = 0; uint8_t *pdu_buffer = NULL; + + ue_security_key=(ue_sa_security_key_t **)calloc(1,sizeof(ue_sa_security_key_t*)*NB_UE_INST); itti_mark_task_ready (TASK_NAS_NRUE); MSC_START_USE(); @@ -823,7 +880,7 @@ void *nas_nrue_task(void *args_p) as_nas_info_t initialNasMsg; memset(&initialNasMsg, 0, sizeof(as_nas_info_t)); - generateRegistrationComplete(&initialNasMsg, NULL); + generateRegistrationComplete(Mod_id,&initialNasMsg, NULL); if(initialNasMsg.length > 0){ MessageDef *message_p; message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); @@ -836,7 +893,7 @@ void *nas_nrue_task(void *args_p) as_nas_info_t pduEstablishMsg; memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t)); - generatePduSessionEstablishRequest(uicc, &pduEstablishMsg); + generatePduSessionEstablishRequest(Mod_id, uicc, &pduEstablishMsg); if(pduEstablishMsg.length > 0){ MessageDef *message_p; message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); @@ -908,18 +965,20 @@ void *nas_nrue_task(void *args_p) msg_type = get_msg_type(pdu_buffer, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length); switch(msg_type){ - case FGS_IDENTITY_REQUEST: - generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3), uicc); - break; - case FGS_AUTHENTICATION_REQUEST: - generateAuthenticationResp(&initialNasMsg, pdu_buffer, uicc); - break; - case FGS_SECURITY_MODE_COMMAND: - generateSecurityModeComplete(&initialNasMsg); - break; - case FGS_DOWNLINK_NAS_TRANSPORT: - decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer); - break; + + case FGS_IDENTITY_REQUEST: + generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3), uicc); + break; + case FGS_AUTHENTICATION_REQUEST: + generateAuthenticationResp(Mod_id,&initialNasMsg, pdu_buffer, uicc); + break; + case FGS_SECURITY_MODE_COMMAND: + nas_itti_kgnb_refresh_req(ue_security_key[Mod_id]->kgnb, instance); + generateSecurityModeComplete(Mod_id,&initialNasMsg); + break; + case FGS_DOWNLINK_NAS_TRANSPORT: + decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer); + break; case FGS_PDU_SESSION_ESTABLISHMENT_ACC: { uint8_t offset = 0; @@ -950,17 +1009,17 @@ void *nas_nrue_task(void *args_p) } } break; - - default: - LOG_W(NR_RRC,"unknow message type %d\n",msg_type); - break; - } - - if(initialNasMsg.length > 0){ - MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); - NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id; - NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data; + default: + LOG_W(NR_RRC,"unknow message type %d\n",msg_type); + break; + } + + if(initialNasMsg.length > 0){ + MessageDef *message_p; + message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); + NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id; + NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data; + NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length; itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message\n"); diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.h b/openair3/NAS/NR_UE/nr_nas_msg_sim.h index fa7496da07..9655f87130 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.h +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.h @@ -69,6 +69,18 @@ #define PAYLOAD_CONTAINER_LENGTH_MIN 3 #define PAYLOAD_CONTAINER_LENGTH_MAX 65537 +/* Security Key for SA UE */ +typedef struct { + uint8_t kausf[32]; + uint8_t kseaf[32]; + uint8_t kamf[32]; + uint8_t knas_int[16]; + uint8_t res[16]; + uint8_t rand[16]; + uint8_t kgnb[32]; +} ue_sa_security_key_t; + + typedef enum fgs_protocol_discriminator_e { /* Protocol discriminator identifier for 5GS Mobility Management */ FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E, diff --git a/openair3/NAS/UE/EMM/SAP/emm_as.c b/openair3/NAS/UE/EMM/SAP/emm_as.c index 10b118eac0..6b226be380 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_as.c +++ b/openair3/NAS/UE/EMM/SAP/emm_as.c @@ -136,17 +136,25 @@ static int _emm_as_encrypt( static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg); -static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *, - ul_info_transfer_req_t *); -static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *, - nas_establish_req_t *); + + static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *); - -static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, ul_info_transfer_req_t *); -static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, ul_info_transfer_req_t *); -static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *); +/* prototyping of the following function modified: the last parameter turned to a void pointer + * instead of a ponter to the union field of the as_msg packed structure. This is to avoid new warnings introduced + * from gcc V9 which warns when accessing fields in a packed structure which may result in an alignment problem + * at run time. Modifications allow gcc to know at compile time that it cannot assume any alignment for those pointers. + * On X86 this is not fatal, as at run time the problem can be fixed (but it's better for perf to avoid). On other + * processor as Arm i think it can end in seg fault + */ +static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *, + void *ul_info_transfer_req_unaligned); +static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *, + void *nas_establish_req_unaligned); +static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, void *ul_info_transfer_req_unaligned); +static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, void *ul_info_transfer_req_unaligned); +static int _emm_as_release_req(const emm_as_release_t *, void *nas_release_req_unaligned); /****************************************************************************/ /****************** E X P O R T E D F U N C T I O N S ******************/ @@ -938,32 +946,32 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg) case _EMMAS_DATA_REQ: as_msg.msgID = _emm_as_data_req(user->emm_data, &msg->u.data, - &as_msg.msg.ul_info_transfer_req); + (void *)(&as_msg.msg.ul_info_transfer_req)); break; case _EMMAS_STATUS_IND: as_msg.msgID = _emm_as_status_ind(user->emm_data, &msg->u.status, - &as_msg.msg.ul_info_transfer_req); + (void *)(&as_msg.msg.ul_info_transfer_req)); break; case _EMMAS_RELEASE_REQ: as_msg.msgID = _emm_as_release_req( &msg->u.release, - &as_msg.msg.nas_release_req); + (void *)(&as_msg.msg.nas_release_req)); break; case _EMMAS_SECURITY_RES: as_msg.msgID = _emm_as_security_res(user->emm_data, &msg->u.security, - &as_msg.msg.ul_info_transfer_req); + (void *)(&as_msg.msg.ul_info_transfer_req)); break; case _EMMAS_ESTABLISH_REQ: as_msg.msgID = _emm_as_establish_req(user->emm_data, &msg->u.establish, - &as_msg.msg.nas_establish_req); + (void *)(&as_msg.msg.nas_establish_req)); break; @@ -1069,10 +1077,10 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg) ** ** ***************************************************************************/ static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, - ul_info_transfer_req_t *as_msg) + void *ul_info_transfer_req_unaligned) { LOG_FUNC_IN; - + ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned; int size = 0; int is_encoded = FALSE; @@ -1165,12 +1173,12 @@ static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg ** ** ***************************************************************************/ static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *msg, - ul_info_transfer_req_t *as_msg) + void *ul_info_transfer_req_unaligned) { LOG_FUNC_IN; int size = 0; - + ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned; LOG_TRACE(INFO, "EMMAS-SAP - Send AS status indication (cause=%d)", msg->emm_cause); @@ -1239,12 +1247,12 @@ static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t ** ** ***************************************************************************/ static int _emm_as_release_req(const emm_as_release_t *msg, - nas_release_req_t *as_msg) + void *nas_release_req_unaligned) { LOG_FUNC_IN; LOG_TRACE(INFO, "EMMAS-SAP - Send AS release request"); - + nas_release_req_t *as_msg = (nas_release_req_t *)nas_release_req_unaligned; /* Setup the AS message */ if (msg->guti) { as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; @@ -1279,10 +1287,10 @@ static int _emm_as_release_req(const emm_as_release_t *msg, ** ** ***************************************************************************/ static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *msg, - ul_info_transfer_req_t *as_msg) + void *ul_info_transfer_req_unaligned) { LOG_FUNC_IN; - + ul_info_transfer_req_t *as_msg=(ul_info_transfer_req_t *)ul_info_transfer_req_unaligned; int size = 0; LOG_TRACE(INFO, "EMMAS-SAP - Send AS security response"); @@ -1373,12 +1381,12 @@ static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_securit ** ** ***************************************************************************/ static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *msg, - nas_establish_req_t *as_msg) + void *nas_establish_req_unaligned) { LOG_FUNC_IN; int size = 0; - + nas_establish_req_t *as_msg = (nas_establish_req_t *)nas_establish_req_unaligned; LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish request"); nas_message_t nas_msg; diff --git a/openair3/NAS/UE/nas_network.c b/openair3/NAS/UE/nas_network.c index f8abba4900..f6b291bb7b 100644 --- a/openair3/NAS/UE/nas_network.c +++ b/openair3/NAS/UE/nas_network.c @@ -141,11 +141,11 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data) case AS_CELL_INFO_CNF: { /* Received cell information confirm */ - const cell_info_cnf_t *info = &msg->msg.cell_info_cnf; - int cell_found = (info->errCode == AS_SUCCESS); - rc = nas_proc_cell_info(user, cell_found, info->tac, - info->cellID, info->rat, - info->rsrp, info->rsrq); + /* remove using pointers to fiels of the packed structure msg as it + * triggers warnings with gcc version 9 */ + const cell_info_cnf_t info = msg->msg.cell_info_cnf; + int cell_found = (info.errCode == AS_SUCCESS); + rc = nas_proc_cell_info(user, cell_found, info.tac, info.cellID, info.rat, info.rsrp, info.rsrq); break; } @@ -157,12 +157,12 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data) case AS_NAS_ESTABLISH_CNF: { /* Received NAS signalling connection establishment confirm */ - const nas_establish_cnf_t *confirm = &msg->msg.nas_establish_cnf; + const nas_establish_cnf_t confirm = msg->msg.nas_establish_cnf; - if ( (confirm->errCode == AS_SUCCESS) || - (confirm->errCode == AS_TERMINATED_NAS) ) { - rc = nas_proc_establish_cnf(user, confirm->nasMsg.data, - confirm->nasMsg.length); + if ( (confirm.errCode == AS_SUCCESS) || + (confirm.errCode == AS_TERMINATED_NAS) ) { + rc = nas_proc_establish_cnf(user, confirm.nasMsg.data, + confirm.nasMsg.length); } else { LOG_TRACE(WARNING, "NET-MAIN - " "Initial NAS message not delivered"); @@ -191,10 +191,10 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data) break; case AS_DL_INFO_TRANSFER_IND: { - const dl_info_transfer_ind_t *info = &msg->msg.dl_info_transfer_ind; + const dl_info_transfer_ind_t info = msg->msg.dl_info_transfer_ind; /* Received downlink data transfer indication */ - rc = nas_proc_dl_transfer_ind(user, info->nasMsg.data, - info->nasMsg.length); + rc = nas_proc_dl_transfer_ind(user, info.nasMsg.data, + info.nasMsg.length); break; } diff --git a/openair3/NGAP/ngap_gNB_handlers.c b/openair3/NGAP/ngap_gNB_handlers.c index 401695473c..2b0e8aab7c 100644 --- a/openair3/NGAP/ngap_gNB_handlers.c +++ b/openair3/NGAP/ngap_gNB_handlers.c @@ -1127,12 +1127,11 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.eUTRAencryptionAlgorithms); NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.eUTRAintegrity_algorithms = BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.eUTRAintegrityProtectionAlgorithms); - /* id-SecurityKey : Copy the security key */ } else {/* ie != NULL */ return -1; } - /* id-MobilityRestrictionList */ + /* id-SecurityKey : Copy the security key */ NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container, NGAP_ProtocolIE_ID_id_SecurityKey, true); @@ -1144,7 +1143,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, return -1; } - /* id-NAS-PDU */ + /* id-MobilityRestrictionList */ NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container, NGAP_ProtocolIE_ID_id_MobilityRestrictionList, false); @@ -1160,6 +1159,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, } + /* id-NAS-PDU */ NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container, NGAP_ProtocolIE_ID_id_NAS_PDU, false); @@ -1171,7 +1171,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, memcpy(NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nas_pdu.buffer, ie->value.choice.NAS_PDU.buf, ie->value.choice.NAS_PDU.size); } - } itti_send_msg_to_task(TASK_RRC_GNB, ue_desc_p->gNB_instance->instance, message_p); diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 86899520a0..78a130b672 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -17,6 +17,7 @@ extern "C" { #include #include #include +#include "openair2/SDAP/nr_sdap/nr_sdap_gnb.h" //#include #pragma pack(1) @@ -74,6 +75,12 @@ class gtpEndPoint { int ipVersion; map ue2te_mapping; map te2ue_mapping; + // we use the same port number for source and destination address + // this allow using non standard gtp port number (different from 2152) + // and so, for example tu run 4G and 5G cores on one system + tcp_udp_port_t get_dstport() { + return (tcp_udp_port_t)atol(addr.destinationService); + } }; class gtpEndPoints { @@ -99,6 +106,8 @@ instance_t legacyInstanceMapping=0; #define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a) #define GTPV1U_HEADER_SIZE (8) + + static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, teid_t teid, uint8_t *Msg,int msgLen, bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) { AssertFatal(extHdrFlag==false,"Not developped"); @@ -302,7 +311,6 @@ static int udpServerSocket(openAddr_s addr) { LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status)); return -1; } - int sockfd=-1; // loop through all the results and bind to the first we can @@ -489,17 +497,18 @@ int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->sgw_S1u_teid[0]); - + tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4, "From legacy code not clear, seems impossible (bearer=%d)\n", create_tunnel_req->eps_bearer_id[i]); int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4; - teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti, + + teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, incoming_rb_id, create_tunnel_req->eps_bearer_id[i], create_tunnel_req->sgw_S1u_teid[i], - create_tunnel_req->sgw_addr[i], 2152, + create_tunnel_req->sgw_addr[i], dstport, pdcp_data_req); create_tunnel_resp->status=0; create_tunnel_resp->rnti=create_tunnel_req->rnti; @@ -557,14 +566,14 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->outgoing_teid[0]); - + tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); 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], 2152, - pdcp_data_req); + create_tunnel_req->outgoing_teid[i], + create_tunnel_req->dst_addr[i], dstport, + sdap_gnb_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; @@ -894,17 +903,11 @@ void *ocp_gtpv1uTask(void *args) { abort(); break; - case GTPV1U_ENB_S1_REQ: + case GTPV1U_REQ: // to be dev: should be removed, to use API - strcpy(addr.originHost, GTPV1U_ENB_S1_REQ(message_p).addrStr); - strcpy(addr.originService, GTPV1U_ENB_S1_REQ(message_p).portStr); - AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n"); - break; - - case GTPV1U_GNB_NG_REQ: - // to be dev: should be removed, to use API - strcpy(addr.originHost, GTPV1U_GNB_NG_REQ(message_p).addrStr); - strcpy(addr.originService, GTPV1U_GNB_NG_REQ(message_p).portStr); + strcpy(addr.originHost, GTPV1U_REQ(message_p).localAddrStr); + strcpy(addr.originService, GTPV1U_REQ(message_p).localPortStr); + strcpy(addr.destinationService,addr.originService); AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n"); break; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 877f607990..d268855566 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -555,6 +555,7 @@ void *trx_usrp_write_thread(void * arg){ s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet; s->tx_md.end_of_burst = last_packet; s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate); + LOG_D(PHY,"usrp_tx_write: tx_count %llu SoB %d, EoB %d, TS %llu\n",(unsigned long long)s->tx_count,s->tx_md.start_of_burst,s->tx_md.end_of_burst,(unsigned long long)timestamp); s->tx_count++; // bit 3 enables gpio (for backward compatibility) @@ -940,6 +941,7 @@ extern "C" { LOG_I(HW, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs); LOG_I(HW, "openair0_cfg[0].clock_source == '%d' (internal = %d, external = %d)\n", openair0_cfg[0].clock_source,internal,external); usrp_state_t *s ; + int choffset = 0; if ( device->priv == NULL) { s=(usrp_state_t *)calloc(sizeof(usrp_state_t),1); @@ -1094,6 +1096,7 @@ extern "C" { if (device->type==USRP_X300_DEV) { openair0_cfg[0].rx_gain_calib_table = calib_table_x310; std::cerr << "-- Using calibration table: calib_table_x310" << std::endl; + s->usrp->set_rx_dc_offset(true); } if (device->type==USRP_N300_DEV) { @@ -1248,10 +1251,10 @@ extern "C" { for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) { if (iusrp->set_rx_rate(openair0_cfg[0].sample_rate,i); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i); + s->usrp->set_rx_rate(openair0_cfg[0].sample_rate,i+choffset); + s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i+choffset); set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust); - ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i); + ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i+choffset); // limit to maximum gain double gain=openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i]; if ( gain > gain_range.stop()) { @@ -1260,7 +1263,7 @@ extern "C" { gain=gain_range.stop(); } - s->usrp->set_rx_gain(gain,i); + s->usrp->set_rx_gain(gain,i+choffset); LOG_I(HW,"RX Gain %d %f (%f) => %f (max %f)\n",i, openair0_cfg[0].rx_gain[i],openair0_cfg[0].rx_gain_offset[i], openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],gain_range.stop()); @@ -1274,9 +1277,9 @@ extern "C" { ::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i); if (iusrp->set_tx_rate(openair0_cfg[0].sample_rate,i); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i); - s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i); + s->usrp->set_tx_rate(openair0_cfg[0].sample_rate,i+choffset); + s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i+choffset); + s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i+choffset); LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]); } } @@ -1303,41 +1306,41 @@ extern "C" { s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps()); for (int i = 0; irx_stream = s->usrp->get_rx_stream(stream_args_rx); uhd::stream_args_t stream_args_tx("sc16", "sc16"); for (int i = 0; itx_stream = s->usrp->get_tx_stream(stream_args_tx); /* Setting TX/RX BW after streamers are created due to USRP calibration issue */ for(int i=0; i<((int) s->usrp->get_tx_num_channels()) && iusrp->set_tx_bandwidth(openair0_cfg[0].tx_bw,i); + s->usrp->set_tx_bandwidth(openair0_cfg[0].tx_bw,i+choffset); for(int i=0; i<((int) s->usrp->get_rx_num_channels()) && iusrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i); + s->usrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i+choffset); for (int i=0; iusrp->get_rx_rate(i)/1e6); - LOG_I(HW," Actual RX frequency: %fGHz...\n", s->usrp->get_rx_freq(i)/1e9); - LOG_I(HW," Actual RX gain: %f...\n", s->usrp->get_rx_gain(i)); - LOG_I(HW," Actual RX bandwidth: %fM...\n", s->usrp->get_rx_bandwidth(i)/1e6); - LOG_I(HW," Actual RX antenna: %s...\n", s->usrp->get_rx_antenna(i).c_str()); + LOG_I(HW," Actual RX sample rate: %fMSps...\n",s->usrp->get_rx_rate(i+choffset)/1e6); + LOG_I(HW," Actual RX frequency: %fGHz...\n", s->usrp->get_rx_freq(i+choffset)/1e9); + LOG_I(HW," Actual RX gain: %f...\n", s->usrp->get_rx_gain(i+choffset)); + LOG_I(HW," Actual RX bandwidth: %fM...\n", s->usrp->get_rx_bandwidth(i+choffset)/1e6); + LOG_I(HW," Actual RX antenna: %s...\n", s->usrp->get_rx_antenna(i+choffset).c_str()); } for (int i=0; iusrp->get_tx_rate(i)/1e6); - LOG_I(HW," Actual TX frequency: %fGHz...\n", s->usrp->get_tx_freq(i)/1e9); - LOG_I(HW," Actual TX gain: %f...\n", s->usrp->get_tx_gain(i)); - LOG_I(HW," Actual TX bandwidth: %fM...\n", s->usrp->get_tx_bandwidth(i)/1e6); - LOG_I(HW," Actual TX antenna: %s...\n", s->usrp->get_tx_antenna(i).c_str()); + LOG_I(HW," Actual TX sample rate: %fMSps...\n", s->usrp->get_tx_rate(i+choffset)/1e6); + LOG_I(HW," Actual TX frequency: %fGHz...\n", s->usrp->get_tx_freq(i+choffset)/1e9); + LOG_I(HW," Actual TX gain: %f...\n", s->usrp->get_tx_gain(i+choffset)); + LOG_I(HW," Actual TX bandwidth: %fM...\n", s->usrp->get_tx_bandwidth(i+choffset)/1e6); + LOG_I(HW," Actual TX antenna: %s...\n", s->usrp->get_tx_antenna(i+choffset).c_str()); LOG_I(HW," Actual TX packet size: %lu\n",s->tx_stream->get_max_num_samps()); } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf index 0fd0dd4551..0306fe5d0b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf @@ -268,6 +268,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index 2c97e2cad3..c14ad17b42 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -252,6 +252,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf index 3ec84d34ce..ff0fdd96bb 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf @@ -247,6 +247,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index 90ae80fb8d..937790d4ac 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -266,6 +266,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf index cd57096e00..c9a95d59e8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -258,6 +258,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf index 5230fa91ef..524407c4de 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -258,6 +258,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index f90adae46b..d191b67988 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -259,6 +259,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf index 51b252e1a4..2dfa329346 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf @@ -263,6 +263,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf index a0ee7f8a6d..7f0829e40a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf @@ -261,6 +261,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf index 5530f33d65..6248afab2f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf @@ -306,6 +306,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf index 1cd08ec115..6f28cd36c1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf @@ -255,6 +255,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 8a5fbb740f..30194647b8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -255,6 +255,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 705fa277e0..fcbd3c0f02 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -256,6 +256,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 7d8b80f83c..63123b8201 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -271,6 +271,23 @@ THREAD_STRUCT = ( # modelname = "AWGN"; #}; +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf index a1a4972470..217ff76376 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -246,6 +246,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf index 44d238bce2..a1acfc313b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf @@ -258,6 +258,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf index a4df8399ea..540dddad21 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf @@ -256,6 +256,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf index 2899f6982d..edc5eaa0d4 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf @@ -256,6 +256,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf index 2b646fcacd..362a280ccb 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf @@ -247,6 +247,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index 95b05f320b..b1c78bc978 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -268,12 +268,17 @@ security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen # valid values: nea0, nea1, nea2, nea3 - ciphering_algorithms = ( "nea0", "nea2" ); + ciphering_algorithms = ( "nea0" ); # preferred integrity algorithms # the first one of the list that an UE supports in chosen # valid values: nia0, nia1, nia2, nia3 - integrity_algorithms = ( "nia0" ); + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; }; log_config : diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf index f7546cde79..96f2909031 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -288,6 +288,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf index 767459aecb..f51f59ae30 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf @@ -262,6 +262,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf new file mode 100644 index 0000000000..59e507ed3e --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf @@ -0,0 +1,296 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 222; mnc = 01; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 31; //0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 200; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641272; //641032; #641968; 641968=start of ssb at 3600MHz + 82 RBs 641032=center of SSB at center of cell + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=84,L=13 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6368; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6368; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -100; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 5; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; //15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, + +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 2; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; #0x80; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; //8; //7; + nrofDownlinkSymbols = 6; //0; //6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; //0; //4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + amf_ip_address = ( { ipv4 = "192.168.18.99"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + target_enb_x2_ip_address = ( + { ipv4 = "192.168.18.199"; + ipv6 = "192:168:30::17"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.198/24"; + GNB_INTERFACE_NAME_FOR_NGU = "eth0"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.198/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + GNB_IPV4_ADDRESS_FOR_X2C = "192.168.18.198/24"; + GNB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 8; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.80.50,clock_source=internal,time_source= internal" + #clock_src = "external"; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + //parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0", "nea2" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia0" ); +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 05e441d396..ca11c5f852 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -79,7 +79,7 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 11; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) @@ -88,22 +88,12 @@ gNBs = #0=typeA,1=typeB initialDLBWPmappingType_0 = 0; #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 53; + initialDLBWPstartSymbolAndLength_0 = 40; initialDLBWPk0_1 = 0; initialDLBWPmappingType_1 = 0; #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 81; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPstartSymbolAndLength_1 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -162,12 +152,12 @@ gNBs = initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 # this is SS=2 L=12 - initialULBWPstartSymbolAndLength_0 = 53; + initialULBWPstartSymbolAndLength_0 = 41; initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 52; initialULBWPk2_2 = 7; initialULBWPmappingType_2 = 1; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf index 1b0c15ea7a..3bd884b602 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf @@ -283,6 +283,23 @@ THREAD_STRUCT = ( } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 3fd543f70f..62b89188f9 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -230,8 +230,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 100; - pusch_TargetSNRx10 = 200; + pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; } ); @@ -241,7 +240,9 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -252,7 +253,7 @@ RUs = ( nb_rx = 1 att_tx = 0 att_rx = 0; - bands = [7]; + bands = [41]; max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; @@ -280,6 +281,23 @@ rfsimulator : IQfile = "/tmp/rfsimulator.iqs"; }; +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index e69607ee57..ac8622fbc5 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -66,7 +66,7 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -95,7 +95,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 12952; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -230,8 +230,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 100; - pusch_TargetSNRx10 = 200; + pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; } ); @@ -241,7 +240,9 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -252,7 +253,7 @@ RUs = ( nb_rx = 1 att_tx = 0 att_rx = 0; - bands = [7]; + bands = [78]; max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; @@ -280,6 +281,23 @@ rfsimulator : IQfile = "/tmp/rfsimulator.iqs"; }; +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf index 9892f97467..a0d25053b6 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf @@ -306,6 +306,23 @@ rfsimulator : IQfile = "/tmp/rfsimulator.iqs"; }; +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + log_config : { global_log_level ="info"; From 12792eece7910dcb2a1f6eff4ddd84b687f849bf Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 19 Nov 2021 18:52:51 +0100 Subject: [PATCH 23/84] Modifications in the cellGroupConfig container content of F1 UE context response messages --- openair2/RRC/NR/rrc_gNB.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 8dcf0caafa..8aabd29a20 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2783,12 +2783,12 @@ rrc_gNB_decode_dcch( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList; req->cu_to_du_rrc_information = calloc(1,sizeof(cu_to_du_rrc_information_t)); - req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = calloc(1,1024); + req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = calloc(1,4096); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_CapabilityRAT_ContainerList, NULL, (void *)ue_CapabilityRAT_ContainerList, req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, - 1024); + 4096); AssertFatal (enc_rval.encoded > 0, "ASN1 ue_CapabilityRAT_ContainerList encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = (enc_rval.encoded+7)>>3; @@ -3287,7 +3287,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha SEQUENCE_free( &asn_DEF_NR_UE_CapabilityRAT_ContainerList, ue_CapabilityRAT_ContainerList, 1 ); return; } - /*To fill ue_context.UE_Capability_MRDC, ue_context.UE_Capability_nr ...*/ + //To fill ue_context.UE_Capability_MRDC, ue_context.UE_Capability_nr ... int NR_index = -1; for(int i = 0;i < ue_CapabilityRAT_ContainerList->list.count; i++){ if(ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == @@ -3470,7 +3470,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, - (void *)cellGroupConfig, + ue_context_p->ue_context.masterCellGroup, //(void *)cellGroupConfig, resp->du_to_cu_rrc_information, 1024); if (enc_rval.encoded == -1) { @@ -3596,15 +3596,15 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context modification request at the DU\n"); } - if(cellGroupConfig != NULL) { + //if(cellGroupConfig != NULL) { resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, - (void *)cellGroupConfig, + ue_context_p->ue_context.masterCellGroup, //(void *)cellGroupConfig, resp->du_to_cu_rrc_information, 1024); resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; - } + //} itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); } From 2d4453648f699a55afae575241aa224418b94ce3 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 15 Dec 2021 18:38:25 +0100 Subject: [PATCH 24/84] Correct how gtp-u extension header is parsed --- openair2/F1AP/f1ap_cu_ue_context_management.c | 2 +- openair3/ocp-gtpu/gtp_itf.cpp | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 141d89ac51..037be0c8d4 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -144,7 +144,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, (const char *)f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, - f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length) ; + f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); } /* optional */ /* 6.3 measConfig */ diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 59aeb824fb..585a7d5a4b 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -758,10 +758,27 @@ static int Gtpv1uHandleGpdu(int h, return GTPNOK; } - int offset=8; + /*int offset=8; if( msgHdr->E || msgHdr->S ||msgHdr->PN) - offset+=8; + offset+=8;*/ + + +//Minimum length of GTP-U header if non of the optional fields are present + int offset= sizeof(Gtpv1uMsgHeaderT); + + //Consider additional length for GTP-U header if at least one of the optional fields is present + if( msgHdr->E || msgHdr->S ||msgHdr->PN) + offset+=4; + + //Consider the length of 1 or more extension headers that can be present in the GTP-U PDU + if(msgHdr->E) { + while (msgBuf[offset]!=0) { + LOG_D(GTPU, "Extension header length in multiple of 4 bytes is: %d \n", msgBuf[offset]); + offset+=msgBuf[offset]*4 -1; + } + offset++; + } // This context is not good for gtp // frame, ... has no meaning From 0d86181a58865368fc0dfcdbcff9a23a5119c894 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 20 Jan 2022 18:56:44 +0100 Subject: [PATCH 25/84] using uid also in SA --- openair2/RRC/NR/L2_nr_interface.c | 16 ++++++++-------- openair2/RRC/NR/MESSAGES/asn1_msg.c | 13 ++++++------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 4 ++-- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 -- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index eb402092b9..2040c3e11e 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -325,7 +325,14 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, NR_ServingCellConfigCommon_t *scc=RC.nrrrc[module_idP]->carrier.servingcellconfigcommon; memset(&cellGroupConfig,0,sizeof(cellGroupConfig)); - fill_initial_cellGroupConfig(rntiP,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); + ue_context_p->ue_id_rnti = rntiP; + ue_context_p->ue_context.rnti = rntiP; + ue_context_p->ue_context.random_ue_identity = rntiP; + ue_context_p->ue_context.Srb0.Active = 1; + RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); + + fill_initial_cellGroupConfig(ue_context_p->local_uid,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); MessageDef* tmp=itti_alloc_new_message_sized(TASK_RRC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE, sizeof(f1ap_initial_ul_rrc_message_t) + sdu_lenP); f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(tmp); @@ -347,13 +354,6 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, msg->rrc_container_length=sdu_lenP; itti_send_msg_to_task(TASK_DU_F1, 0, tmp); - struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); - ue_context_p->ue_id_rnti = rntiP; - ue_context_p->ue_context.rnti = rntiP; - ue_context_p->ue_context.random_ue_identity = rntiP; - ue_context_p->ue_context.Srb0.Active = 1; - RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); - return(0); } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 84a0cf75d1..ecaaabe045 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -976,7 +976,7 @@ uint8_t do_RRCReject(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -void fill_initial_SpCellConfig(rnti_t rnti, +void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier) { @@ -1009,9 +1009,8 @@ void fill_initial_SpCellConfig(rnti_t rnti, // one symbol (13) NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); pucchres0->pucch_ResourceId=0; - //pucchres0->startingPRB=0; - pucchres0->startingPRB=(8+rnti) % curr_bwp; - LOG_D(NR_RRC, "pucchres0->startPRB %ld rnti %d curr_bwp %d\n", pucchres0->startingPRB, rnti, curr_bwp); + pucchres0->startingPRB=(8+uid) % curr_bwp; + LOG_D(NR_RRC, "pucchres0->startPRB %ld uid %d curr_bwp %d\n", pucchres0->startingPRB, uid, curr_bwp); pucchres0->intraSlotFrequencyHopping=NULL; pucchres0->secondHopPRB=NULL; pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; @@ -1396,7 +1395,7 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); } -void fill_initial_cellGroupConfig(rnti_t rnti, +void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier) { @@ -1490,7 +1489,7 @@ void fill_initial_cellGroupConfig(rnti_t rnti, cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(rnti,cellGroupConfig->spCellConfig,scc,carrier); + fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,carrier); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; @@ -1569,7 +1568,7 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, } else { cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,cellGroupConfig,scc,carrier); + fill_initial_cellGroupConfig(ue_context_pP->local_uid,cellGroupConfig,scc,carrier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 6803cf21d7..cb971acd60 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -100,12 +100,12 @@ void do_SpCellConfig(gNB_RRC_INST *rrc, uint8_t do_RRCReject(uint8_t Mod_id, uint8_t *const buffer); -void fill_initial_SpCellConfig(rnti_t rnti, +void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); -void fill_initial_cellGroupConfig(rnti_t rnti, +void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 30604cd015..1bde92568c 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -889,9 +889,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - NR_PUCCH_Resource_t *pucchres1=calloc(1,sizeof(*pucchres1)); NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); - NR_PUCCH_Resource_t *pucchres3=calloc(1,sizeof(*pucchres3)); pucchres0->pucch_ResourceId=1; pucchres0->startingPRB= (8 + uid) % curr_bwp; From 299ba03b841ab63dc930bebf2a32f0512e8ac8f2 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 22 Dec 2021 10:43:08 +0100 Subject: [PATCH 26/84] passing UECAP structure to RRC reconfiguration functions --- openair1/SIMULATION/NR_PHY/dlsim.c | 3 ++- openair1/SIMULATION/NR_PHY/ulsim.c | 3 ++- openair2/RRC/NR/MESSAGES/asn1_msg.c | 20 +++++++++++--------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 6 ++++++ openair2/RRC/NR/nr_rrc_proto.h | 2 ++ openair2/RRC/NR/rrc_gNB.c | 8 ++++++++ openair2/RRC/NR/rrc_gNB_nsa.c | 2 ++ openair2/RRC/NR/rrc_gNB_reconfig.c | 3 +++ 8 files changed, 36 insertions(+), 11 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 84c6c3ee5f..8e84c830fc 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -775,7 +775,8 @@ int main(int argc, char **argv) prepare_scd(scd); - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 6, 0, 0, 0); + // TODO do a UECAP for phy-sim + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, NULL, 0, 1, n_tx, 6, 0, 0, 0); /* RRC parameter validation for secondaryCellGroup */ fix_scd(scd); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index db8d54f86d..fc7b7c6372 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -716,7 +716,8 @@ int main(int argc, char **argv) prepare_scd(scd); - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0, 0, 0); + // TODO do a UECAP for phy-sim + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, NULL, 0, 1, n_tx, 0, 0, 0, 0); // xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index ecaaabe045..6c209381af 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1395,6 +1395,12 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); } +void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, + rrc_gNB_carrier_data_t *carrier, + NR_UE_NR_Capability_t *uecap) { + +} + void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, @@ -1814,6 +1820,8 @@ int16_t do_RRCReconfiguration( NR_SDAP_Config_t *sdap_config, NR_MeasConfig_t *meas_config, struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, + rrc_gNB_ue_context_t *const ue_context_pP, + rrc_gNB_carrier_data_t *carrier, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig) //------------------------------------------------------------------------------ @@ -1850,15 +1858,6 @@ int16_t do_RRCReconfiguration( ie->radioBearerConfig->srb3_ToRelease = NULL; ie->radioBearerConfig->drb_ToReleaseList = DRB_releaseList; } - /******************** Secondary Cell Group ********************/ - // rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier); - // fill_default_secondaryCellGroup( carrier->servingcellconfigcommon, - // ue_context_pP->ue_context.secondaryCellGroup, - // 1, - // 1, - // carrier->pdsch_AntennaPorts, - // carrier->initial_csi_index[ue_context_p->local_uid + 1], - // ue_context_pP->local_uid); /******************** Meas Config ********************/ // measConfig @@ -1874,6 +1873,9 @@ int16_t do_RRCReconfiguration( } if(cellGroupConfig!=NULL){ + update_cellGroupConfig(cellGroupConfig, + carrier, + ue_context_pP->ue_context.UE_Capability_nr); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)cellGroupConfig, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index cb971acd60..7fe08704c2 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -110,6 +110,10 @@ void fill_initial_cellGroupConfig(int uid, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); +void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, + rrc_gNB_carrier_data_t *carrier, + NR_UE_NR_Capability_t *uecap); + void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup); uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, @@ -145,6 +149,8 @@ int16_t do_RRCReconfiguration( NR_SDAP_Config_t *sdap_config, NR_MeasConfig_t *meas_config, struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, + rrc_gNB_ue_context_t *const ue_context_pP, + rrc_gNB_carrier_data_t *carrier, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig); diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 22109c3029..7309bcf2d9 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -76,6 +76,7 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti); void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_NR_Capability_t *uecap, int scg_id, int servCellIndex, int dl_antenna_ports, @@ -90,6 +91,7 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon NR_ServingCellConfig_t *servingcellconfigdedicated, NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_NR_Capability_t *uecap, int dl_antenna_ports, int minRXTXTIMEpdsch, int do_csirs, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2c2020412d..7824d4c85b 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -759,6 +759,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( NULL, dedicatedNAS_MessageList, NULL, + NULL, + NULL, NULL); free(ue_context_pP->ue_context.nas_pdu.buffer); @@ -1028,6 +1030,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( NULL, NULL, dedicatedNAS_MessageList, + ue_context_pP, + &rrc->carrier, NULL, cellGroupConfig); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Reconfiguration\n"); @@ -1137,6 +1141,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( NULL, dedicatedNAS_MessageList, NULL, + NULL, + NULL, NULL); ue_context_pP->ue_context.pdu_session_release_command_flag = 1; @@ -1706,6 +1712,8 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( NULL, // MeasObj_list, NULL, NULL, + NULL, + NULL, NULL); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Reconfiguration\n"); diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 15caff0b4d..42a39a4fa8 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -266,6 +266,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ue_context_p->ue_context.spCellConfig->spCellConfigDedicated, reconfig_ies, ue_context_p->ue_context.secondaryCellGroup, + ue_context_p->ue_context.UE_Capability_nr, carrier->pdsch_AntennaPorts, carrier->minRXTXTIME, carrier->do_CSIRS, @@ -276,6 +277,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ NULL, reconfig_ies, ue_context_p->ue_context.secondaryCellGroup, + ue_context_p->ue_context.UE_Capability_nr, carrier->pdsch_AntennaPorts, carrier->minRXTXTIME, carrier->do_CSIRS, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 1bde92568c..d35c5bf7a2 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -52,6 +52,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_NR_Capability_t *uecap, int scg_id, int servCellIndex, int dl_antenna_ports, @@ -1346,6 +1347,7 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon NR_ServingCellConfig_t *servingcellconfigdedicated, NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_NR_Capability_t *uecap, int dl_antenna_ports, int minRXTXTIME, int do_csirs, @@ -1360,6 +1362,7 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon fill_default_secondaryCellGroup(servingcellconfigcommon, servingcellconfigdedicated, secondaryCellGroup, + uecap, 1, 1, dl_antenna_ports, From dd6dac13928dc5c93ad4529854d5fd550a76c389 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 21 Jan 2022 16:16:02 +0100 Subject: [PATCH 27/84] function to configure pucch resource set 0 --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 24 ++-------------------- openair2/RRC/NR/nr_rrc_config.c | 29 +++++++++++++++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 2 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 31 +++++++---------------------- 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 6c209381af..dce972ab3a 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -995,30 +995,10 @@ void fill_initial_SpCellConfig(int uid, initialUplinkBWP->pucch_Config->choice.setup=pucch_Config; pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - *pucchresset0id0=0; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - pucchresset0->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; - // configure one single PUCCH0 opportunity for initial connection procedure - // one symbol (13) - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - pucchres0->pucch_ResourceId=0; - pucchres0->startingPRB=(8+uid) % curr_bwp; - LOG_D(NR_RRC, "pucchres0->startPRB %ld uid %d curr_bwp %d\n", pucchres0->startingPRB, uid, curr_bwp); - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL); + initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 6b7f9a21b9..b8d6b6ee1b 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -102,6 +102,35 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); } } +} +// PUCCH resource set 0 for configuration with O_uci <= 2 bits and/or a positive or negative SR (section 9.2.1 of 38.213) +void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap) { + + NR_PUCCH_ResourceSet_t *pucchresset = calloc(1,sizeof(*pucchresset)); + pucchresset->pucch_ResourceSetId = 0; + NR_PUCCH_ResourceId_t *pucchid=calloc(1,sizeof(*pucchid)); + *pucchid=0; + ASN_SEQUENCE_ADD(&pucchresset->resourceList.list,pucchid); + pucchresset->maxPayloadSize=NULL; + + if(uecap) { + long *pucch_F0_2WithoutFH = uecap->phy_Parameters.phy_ParametersFRX_Diff->pucch_F0_2WithoutFH; + AssertFatal(pucch_F0_2WithoutFH == NULL,"UE does not support PUCCH F0 without frequency hopping. Current configuration is without FH\n"); + } + + NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); + pucchres0->pucch_ResourceId=*pucchid; + pucchres0->startingPRB= (8 + uid) % curr_bwp; + pucchres0->intraSlotFrequencyHopping=NULL; + pucchres0->secondHopPRB=NULL; + pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; + pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); + pucchres0->format.choice.format0->initialCyclicShift=0; + pucchres0->format.choice.format0->nrofSymbols=1; + pucchres0->format.choice.format0->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset); } diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 192fee754e..af1fca4e0f 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -113,6 +113,6 @@ typedef struct physicalcellgroup_s{ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); - +void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index d35c5bf7a2..18c155f5b8 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -864,22 +864,20 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco if (!servingcellconfigdedicated) { ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); } + ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); + pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); + pucch_Config->resourceToReleaseList = NULL; + + config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); + NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - *pucchresset0id0=1; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - pucchresset0->maxPayloadSize=NULL; - - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); - pucchresset1->pucch_ResourceSetId = 1; NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); *pucchresset1id0=2; @@ -887,22 +885,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucchresset1->maxPayloadSize=NULL; ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); - pucch_Config->resourceToReleaseList = NULL; - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); - - pucchres0->pucch_ResourceId=1; - pucchres0->startingPRB= (8 + uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - pucchres2->pucch_ResourceId=2; pucchres2->startingPRB=0; pucchres2->intraSlotFrequencyHopping=NULL; From 975f7e868a2076905b4ae4686d528aa8c84973f8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 21 Jan 2022 19:15:50 +0100 Subject: [PATCH 28/84] function to configure pucch resource set 1 (format2) --- cmake_targets/CMakeLists.txt | 1 + openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 +++ openair2/RRC/NR/nr_rrc_config.c | 47 +++++++++++++++++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 1 + openair2/RRC/NR/rrc_gNB_reconfig.c | 37 ++--------------------- 5 files changed, 56 insertions(+), 34 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index bf3bb2b017..f0c84fbbe6 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2029,6 +2029,7 @@ set(NR_L2_SRC_UE ${NR_SDAP_SRC} ${NR_UE_RRC_DIR}/L2_interface_ue.c ${NR_UE_RRC_DIR}/main_ue.c + ${NR_RRC_DIR}/nr_rrc_config.c ${NR_UE_RRC_DIR}/rrc_UE.c ${NR_UE_RRC_DIR}/rrc_nsa.c ) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index dce972ab3a..15dfa47f66 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1379,6 +1379,10 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, rrc_gNB_carrier_data_t *carrier, NR_UE_NR_Capability_t *uecap) { + NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; + NR_BWP_UplinkDedicated_t *initialUplinkBWP = SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + NR_PUCCH_Config_t *pucch_Config = initialUplinkBWP->pucch_Config->choice.setup; + config_pucch_resset1(pucch_Config, uecap); } void fill_initial_cellGroupConfig(int uid, diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index b8d6b6ee1b..f4ab5fdd0f 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -134,3 +134,50 @@ void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset); } + +// PUCCH resource set 1 for configuration with O_uci > 2 bits (currently format2) +void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap) { + + NR_PUCCH_ResourceSet_t *pucchresset=calloc(1,sizeof(*pucchresset)); + pucchresset->pucch_ResourceSetId = 1; + NR_PUCCH_ResourceId_t *pucchressetid=calloc(1,sizeof(*pucchressetid)); + *pucchressetid=2; + ASN_SEQUENCE_ADD(&pucchresset->resourceList.list,pucchressetid); + pucchresset->maxPayloadSize=NULL; + + if(uecap) { + long *pucch_F0_2WithoutFH = uecap->phy_Parameters.phy_ParametersFRX_Diff->pucch_F0_2WithoutFH; + AssertFatal(pucch_F0_2WithoutFH == NULL,"UE does not support PUCCH F2 without frequency hopping. Current configuration is without FH\n"); + } + + NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + pucchres2->pucch_ResourceId=*pucchressetid; + pucchres2->startingPRB=0; + pucchres2->intraSlotFrequencyHopping=NULL; + pucchres2->secondHopPRB=NULL; + pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; + pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); + pucchres2->format.choice.format2->nrofPRBs=8; + pucchres2->format.choice.format2->nrofSymbols=1; + pucchres2->format.choice.format2->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); + + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset); + + pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); + pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; + NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); + pucch_Config->format2->choice.setup = pucchfmt2; + pucchfmt2->interslotFrequencyHopping=NULL; + pucchfmt2->additionalDMRS=NULL; + pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); + *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; + pucchfmt2->nrofSlots=NULL; + pucchfmt2->pi2BPSK=NULL; + + // to check UE capabilities for that in principle + pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); + *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + +} + diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index af1fca4e0f..78416f7ecf 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -114,5 +114,6 @@ typedef struct physicalcellgroup_s{ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap); +void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 18c155f5b8..98dd8ee137 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -45,6 +45,7 @@ #include "SIMULATION/TOOLS/sim.h" #include "executables/softmodem-common.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" +#include "nr_rrc_config.h" #define false 0 #define true 1 @@ -875,40 +876,8 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; - config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); - - NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); - pucchresset1->pucch_ResourceSetId = 1; - NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); - *pucchresset1id0=2; - ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); - pucchresset1->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); - - NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); - pucchres2->pucch_ResourceId=2; - pucchres2->startingPRB=0; - pucchres2->intraSlotFrequencyHopping=NULL; - pucchres2->secondHopPRB=NULL; - pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; - pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); - pucchres2->format.choice.format2->nrofPRBs=8; - pucchres2->format.choice.format2->nrofSymbols=1; - pucchres2->format.choice.format2->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); - - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); // <= 2 bits + config_pucch_resset1(pucch_Config, uecap); // > 2 bits // for scheduling requestresource pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); From 9408c3c0b0647c2601f04c1f180d6a93bfb3ac56 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 26 Jan 2022 13:58:57 +0100 Subject: [PATCH 29/84] function to set dl_DataToUL_ACK --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 10 +--------- openair2/RRC/NR/nr_rrc_config.c | 11 +++++++++++ openair2/RRC/NR/nr_rrc_config.h | 1 + openair2/RRC/NR/rrc_gNB_reconfig.c | 10 +++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 15dfa47f66..afb42e14e1 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1149,15 +1149,7 @@ void fill_initial_SpCellConfig(int uid, *schedulingRequestResourceConfig->resource = 0; ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(carrier->minRXTXTIME >=2 && carrier->minRXTXTIME <7, - "check minRXTXTIME %d\n",carrier->minRXTXTIME); - *delay[i] = (i+carrier->minRXTXTIME); - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } + set_dl_DataToUL_ACK(pucch_Config, carrier->minRXTXTIME); SpCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->initialDownlinkBWP)); NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f4ab5fdd0f..207b68e2d4 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -104,6 +104,17 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ } } +void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time) { + + pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); + long *delay[8]; + for (int i=0;i<8;i++) { + delay[i] = calloc(1,sizeof(*delay[i])); + *delay[i] = i+min_feedback_time; + ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); + } +} + // PUCCH resource set 0 for configuration with O_uci <= 2 bits and/or a positive or negative SR (section 9.2.1 of 38.213) void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap) { diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 78416f7ecf..62762ee7e4 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -115,5 +115,6 @@ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap); void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); +void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 98dd8ee137..b8b3485938 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -893,13 +893,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucch_Config->schedulingRequestResourceToReleaseList=NULL; pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - *delay[i] = i+minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } + + set_dl_DataToUL_ACK(pucch_Config, minRXTXTIME); + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); pucchspatial->pucch_SpatialRelationInfoId = 1; From d29b17a21151f97a11805f64eceea76e1a440dc7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 26 Jan 2022 17:46:26 +0100 Subject: [PATCH 30/84] function to configure SR --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 77 ++++++-------------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 2 +- openair2/RRC/NR/nr_rrc_config.c | 27 +++++++ openair2/RRC/NR/nr_rrc_config.h | 2 + openair2/RRC/NR/rrc_gNB_reconfig.c | 21 +----- 6 files changed, 57 insertions(+), 78 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 85bb10290a..b452327c08 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2271,11 +2271,9 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot){ // start the sr-prohibittimer : rel 9 and above if (mac->scheduling_info.sr_ProhibitTimer > 0) { // timer configured mac->scheduling_info.sr_ProhibitTimer--; - mac->scheduling_info. - sr_ProhibitTimer_Running = 1; + mac->scheduling_info.sr_ProhibitTimer_Running = 1; } else { - mac->scheduling_info. - sr_ProhibitTimer_Running = 0; + mac->scheduling_info.sr_ProhibitTimer_Running = 0; } //mac->ul_active =1; return (1); //instruct phy to signal SR diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index afb42e14e1..bc03a74026 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -977,9 +977,11 @@ uint8_t do_RRCReject(uint8_t Mod_id, } void fill_initial_SpCellConfig(int uid, - NR_SpCellConfig_t *SpCellConfig, + NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier) { + + NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); SpCellConfig->servCellIndex = NULL; SpCellConfig->reconfigurationWithSync = NULL; @@ -1127,27 +1129,7 @@ void fill_initial_SpCellConfig(int uid, srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - // configure Scheduling request - // 40 slot period - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID= 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). - // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. - // Check for above configuration and exit for now if it is not the case - AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, - "SCS != 30kHz\n"); - AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, - "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = 0; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + schedulingrequest_config(cellGroupConfig->mac_CellGroupConfig, pucch_Config); set_dl_DataToUL_ACK(pucch_Config, carrier->minRXTXTIME); @@ -1431,36 +1413,25 @@ void fill_initial_cellGroupConfig(int uid, cellGroupConfig->rlc_BearerToReleaseList = NULL; /* mac CellGroup Config */ - if (1) { - mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig)); - if (1) { - mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist; - schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); - schedulingrequestlist->schedulingRequestId = 0; - schedulingrequestlist->sr_ProhibitTimer = CALLOC(1,sizeof(*schedulingrequestlist->sr_ProhibitTimer)); - *(schedulingrequestlist->sr_ProhibitTimer) = 0; - schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; - ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); - } - mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config)); - mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; - mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80; - mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config)); - mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; - mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); - struct NR_TAG *tag=calloc(1,sizeof(*tag)); - tag->tag_Id = 0; - tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; - ASN_SEQUENCE_ADD(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config)); - mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; - mac_CellGroupConfig->phr_Config->choice.setup = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); - mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf10; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1; - } + mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig)); + + mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config)); + mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; + mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80; + mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config)); + mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; + mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); + struct NR_TAG *tag=calloc(1,sizeof(*tag)); + tag->tag_Id = 0; + tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; + ASN_SEQUENCE_ADD(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); + mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config)); + mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; + mac_CellGroupConfig->phr_Config->choice.setup = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); + mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf10; + mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10; + mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1; + cellGroupConfig->mac_CellGroupConfig = mac_CellGroupConfig; physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig)); @@ -1471,7 +1442,7 @@ void fill_initial_cellGroupConfig(int uid, cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,carrier); + fill_initial_SpCellConfig(uid,cellGroupConfig,scc,carrier); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 7fe08704c2..482bee16be 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -101,7 +101,7 @@ uint8_t do_RRCReject(uint8_t Mod_id, uint8_t *const buffer); void fill_initial_SpCellConfig(int uid, - NR_SpCellConfig_t *SpCellConfig, + NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 207b68e2d4..fdd5fac30a 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -192,3 +192,30 @@ void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t } +void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + NR_PUCCH_Config_t *pucch_Config) { + + mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); + mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); + schedulingrequestlist->schedulingRequestId = 0; + schedulingrequestlist->sr_ProhibitTimer = NULL; + schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; + ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + + // format with <=2 bits in pucch resource set 0 + NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[0]; + // assigning the 1st pucch resource in the set to scheduling request + NR_PUCCH_ResourceId_t *pucchressetid = pucchresset->resourceList.list.array[0]; + + pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); + NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); + schedulingRequestResourceConfig->schedulingRequestResourceId = 1; + schedulingRequestResourceConfig->schedulingRequestID = 0; + schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; + schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); + *schedulingRequestResourceConfig->resource = *pucchressetid; + ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); +} diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 62762ee7e4..cd418e21f4 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -116,5 +116,7 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap); void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); +void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + NR_PUCCH_Config_t *pucch_Config); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index b8b3485938..7bf2da09fb 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -96,15 +96,6 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->mac_CellGroupConfig=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig)); secondaryCellGroup->mac_CellGroupConfig->drx_Config = NULL; - secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig)); - secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - NR_SchedulingRequestToAddMod_t *SchedulingRequestConf = calloc(1,sizeof(*SchedulingRequestConf)); - SchedulingRequestConf->schedulingRequestId = 0; //Could be changed - SchedulingRequestConf->sr_ProhibitTimer = calloc(1,sizeof(*SchedulingRequestConf->sr_ProhibitTimer)); - *SchedulingRequestConf->sr_ProhibitTimer = NR_SchedulingRequestToAddMod__sr_ProhibitTimer_ms16; - SchedulingRequestConf->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n32; - ASN_SEQUENCE_ADD(&secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list,SchedulingRequestConf); - secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToReleaseList = NULL; secondaryCellGroup->mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->bsr_Config)); secondaryCellGroup->mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; @@ -879,17 +870,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); // <= 2 bits config_pucch_resset1(pucch_Config, uecap); // > 2 bits - // for scheduling requestresource - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = 1; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + schedulingrequest_config(secondaryCellGroup->mac_CellGroupConfig, pucch_Config); pucch_Config->schedulingRequestResourceToReleaseList=NULL; pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; From 2e0823a7ae49680b781fff67636b3d47c84672db Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 1 Feb 2022 14:03:42 +0100 Subject: [PATCH 31/84] Change mapping between DRB id and channel id for interoperability with Accelleran CU -Some hardcodings also added to be removed later --- openair2/F1AP/f1ap_decoder.c | 2 +- openair2/F1AP/f1ap_du_task.c | 2 +- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 16 +++++++++------- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index 60b3f94310..beecf70401 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -33,7 +33,7 @@ #include "f1ap_common.h" #include "f1ap_decoder.h" -int asn1_decoder_xer_print = 0; +int asn1_decoder_xer_print = 1; static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) { //MessageDef *message_p; diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 03d5810486..b8bf99ad89 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -127,7 +127,7 @@ void *F1AP_DU_task(void *arg) { LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n"); f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg); createF1inst(false, myInstance, msgSetup); - getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu(msgSetup->CU_f1_ip_address.ipv4_address, + getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu("192.168.18.91", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" msgSetup->CUport, msgSetup->DU_f1_ip_address.ipv4_address, msgSetup->DUport); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 78e06d37e2..dad0c8052f 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -166,7 +166,7 @@ void mac_rlc_data_ind ( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; default: rb = NULL; break; } @@ -207,7 +207,7 @@ tbs_size_t mac_rlc_data_req( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; default: rb = NULL; LOG_E(RLC, "In %s:%d:%s: data request for unknown RB with LCID 0x%02x !\n", __FILE__, __LINE__, __FUNCTION__, channel_idP); @@ -215,10 +215,12 @@ tbs_size_t mac_rlc_data_req( } if (rb != NULL) { + LOG_D(RLC, "MAC PDU to get created for channel_idP:%d \n", channel_idP); rb->set_time(rb, nr_rlc_current_time); maxsize = tb_sizeP; ret = rb->generate_pdu(rb, buffer_pP, maxsize); } else { + LOG_D(RLC, "MAC PDU failed to get created for channel_idP:%d \n", channel_idP); ret = 0; } @@ -253,7 +255,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; default: rb = NULL; break; } @@ -316,7 +318,7 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; //4 default: rb = NULL; break; } @@ -751,7 +753,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; int drb_id = s->drb_Identity; - int channel_id = rlc_BearerConfig->logicalChannelIdentity; + //int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; int t_status_prohibit; @@ -768,11 +770,11 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ exit(1); } - if (channel_id != drb_id + 3) { + /*if (channel_id != drb_id + 3) { LOG_E(RLC, "%s:%d:%s: todo, remove this limitation\n", __FILE__, __LINE__, __FUNCTION__); exit(1); - } + }*/ logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index a2b2feb52c..46353110ca 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1647,7 +1647,7 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr rlc_BearerConfig_drb->logicalChannelIdentity = 4; rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; + rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 4; //1; rlc_BearerConfig_drb->reestablishRLC = NULL; rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); rlc_Config_drb->present = NR_RLC_Config_PR_am; From 8d7df8d164005d27a9ad7b3e02fea4216eb6bbfb Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 7 Feb 2022 19:28:51 +0100 Subject: [PATCH 32/84] rrc configuration for pucch power control --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 1 + openair2/RRC/NR/nr_rrc_config.c | 47 +++++++++++++++++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 1 + openair2/RRC/NR/rrc_gNB_reconfig.c | 36 +--------------------- 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index bc03a74026..a36dd3e56b 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1357,6 +1357,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_BWP_UplinkDedicated_t *initialUplinkBWP = SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; NR_PUCCH_Config_t *pucch_Config = initialUplinkBWP->pucch_Config->choice.setup; config_pucch_resset1(pucch_Config, uecap); + set_pucch_power_config(pucch_Config, carrier->do_CSIRS); } void fill_initial_cellGroupConfig(int uid, diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index fdd5fac30a..8dc6a21c92 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -192,6 +192,53 @@ void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t } +void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs) { + + pucch_Config->pucch_PowerControl = calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); + NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); + p00->p0_PUCCH_Id = 1; + p00->p0_PUCCH_Value = 0; + pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); + ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); + + pucch_Config->pucch_PowerControl->pathlossReferenceRSs = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->pathlossReferenceRSs)); + struct NR_PUCCH_PathlossReferenceRS *PL_ref_RS = calloc(1,sizeof(*PL_ref_RS)); + PL_ref_RS->pucch_PathlossReferenceRS_Id = 0; + if(do_csirs) { + PL_ref_RS->referenceSignal.present = NR_PUCCH_PathlossReferenceRS__referenceSignal_PR_csi_RS_Index; + PL_ref_RS->referenceSignal.choice.csi_RS_Index = 0; + } + else { + PL_ref_RS->referenceSignal.present = NR_PUCCH_PathlossReferenceRS__referenceSignal_PR_ssb_Index; + PL_ref_RS->referenceSignal.choice.ssb_Index = 0; + } + ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->pathlossReferenceRSs->list,PL_ref_RS); + + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; + + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + pucch_Config->spatialRelationInfoToReleaseList=NULL; + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + if(do_csirs) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } + + pucchspatial->pucch_PathlossReferenceRS_Id = PL_ref_RS->pucch_PathlossReferenceRS_Id; + pucchspatial->p0_PUCCH_Id = p00->p0_PUCCH_Id; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); +} + void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config) { diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index cd418e21f4..f6df28cf9c 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -116,6 +116,7 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap); void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); +void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config); diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 7bf2da09fb..aaf8159a03 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -876,41 +876,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; set_dl_DataToUL_ACK(pucch_Config, minRXTXTIME); - - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(do_csirs) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; + set_pucch_power_config(pucch_Config, do_csirs); if (!servingcellconfigdedicated) { // copy pusch_Config from dedicated initialBWP From dccbd9279a9c2f41a6b552a02027ec91b1ff855e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 9 Feb 2022 11:05:23 +0100 Subject: [PATCH 33/84] Some hardcoded values in F1AP for testing with Accelleran to be removed later --- openair2/F1AP/f1ap_du_interface_management.c | 2 +- openair2/F1AP/f1ap_du_task.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 0777db864c..2bca8f7e10 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -186,7 +186,7 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { INT8_TO_OCTET_STRING(1,&SliceSupport_item->sNSSAI.sST); //OCTET_STRING_fromBuf(&SliceSupport_item->sNSSAI.sST, "1", 1); asn1cCalloc(SliceSupport_item->sNSSAI.sD, tmp); - INT24_TO_OCTET_STRING(1,tmp); + INT24_TO_OCTET_STRING(10203,tmp); //OCTET_STRING_fromBuf(tmp, "1",1); //} diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index b8bf99ad89..1a99e75d31 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -127,7 +127,7 @@ void *F1AP_DU_task(void *arg) { LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n"); f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg); createF1inst(false, myInstance, msgSetup); - getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu("192.168.18.91", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" + getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu("172.21.10.9",//"172.21.9.5", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" msgSetup->CUport, msgSetup->DU_f1_ip_address.ipv4_address, msgSetup->DUport); From e5c6ee599cb9e4087830a918b9ad83bdaf8cfaff Mon Sep 17 00:00:00 2001 From: matzakos Date: Mon, 28 Feb 2022 21:51:41 +0100 Subject: [PATCH 34/84] Merge with latest updates of develop and fixes for F1 -Problem when parsing UE_RAT_container_list at the DU through UE context setup request -Some debug logs added to be removed once this is fixed --- openair2/F1AP/f1ap_du_ue_context_management.c | 1 + openair2/RRC/NR/rrc_gNB.c | 18 ++++++++++++++---- openair2/RRC/NR_UE/rrc_UE.c | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 1a4fbe38a5..30dec1de08 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -140,6 +140,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = (uint8_t *)calloc(1,ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size); memcpy(f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->buf, ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size); f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = ieCuRrcInfo->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList->size; + LOG_I(F1AP, "Size f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length: %d \n", f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); } } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d61a7547da..48987b6a97 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2512,17 +2512,27 @@ rrc_gNB_decode_dcch( NR_UECapabilityInformation__criticalExtensions_PR_ueCapabilityInformation ) { struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList = ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList; - + if(ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList!=NULL){ + LOG_I(NR_RRC, "ue_CapabilityRAT_ContainerList is present \n"); req->cu_to_du_rrc_information = calloc(1,sizeof(cu_to_du_rrc_information_t)); req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList = calloc(1,4096); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_CapabilityRAT_ContainerList, NULL, - (void *)ue_CapabilityRAT_ContainerList, + (void *)ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList,//ue_CapabilityRAT_ContainerList, req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, 4096); AssertFatal (enc_rval.encoded > 0, "ASN1 ue_CapabilityRAT_ContainerList encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length = (enc_rval.encoded+7)>>3; + LOG_I(NR_RRC, "Printing content of UE capabilityRANContainerList: \n"); + for(int i=0; icu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length; i++){ + printf("%x ", *(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList+i)); + } + printf("\n"); + } + else{ + LOG_I(NR_RRC, "ue_CapabilityRAT_ContainerList is not present \n"); + } } itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); } @@ -2994,7 +3004,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha if(req->cu_to_du_rrc_information!=NULL){ - if(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ + /*if(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ LOG_I(NR_RRC, "Length of ue_CapabilityRAT_ContainerList is: %d \n", (int) req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList; asn_dec_rval_t dec_rval = uper_decode_complete( NULL, @@ -3078,7 +3088,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha //TODO } } - } + }*/ } NR_CellGroupConfig_t *cellGroupConfig; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 2fa0583074..5da690920c 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2719,9 +2719,9 @@ nr_rrc_ue_process_ueCapabilityEnquiry( AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - } + //} LOG_I(NR_RRC, "UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #ifdef ITTI_SIM From d4b566ceb83df42f08e43746c3d5017e80adc86b Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 3 Mar 2022 17:21:23 +0100 Subject: [PATCH 35/84] Update ori.h for AW2S RU --- targets/ARCH/AW2SORI/ori.h | 113 ++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 9 deletions(-) diff --git a/targets/ARCH/AW2SORI/ori.h b/targets/ARCH/AW2SORI/ori.h index d4a4f2cbbf..3650d15ec6 100644 --- a/targets/ARCH/AW2SORI/ori.h +++ b/targets/ARCH/AW2SORI/ori.h @@ -2,8 +2,8 @@ * @file ori.h * @brief Open Radio Interface (ORI) C library header file. * @author AW2S (http://www.aw2s.com) -* @version 1.6 -* @date July 29, 2019 +* @version 1.8 +* @date January 18, 2022 * * This file is the AW2S REC ORI C library header, and contains all necessary * functions prototypes, enumerations, data structures and type definitions @@ -14,7 +14,7 @@ #define ORI_H_ #define ORILIB_VERSION_MAJOR 1 -#define ORILIB_VERSION_MINOR 6 +#define ORILIB_VERSION_MINOR 8 #include @@ -144,10 +144,14 @@ typedef enum ORI_ObjectType_TxEUtraFDD, /**< */ ORI_ObjectType_TxEUtraTDD, /**< */ ORI_ObjectType_TxGSM, /**< */ + ORI_ObjectType_TxNRFDD, /**< */ + ORI_ObjectType_TxNRTDD, /**< */ ORI_ObjectType_RxUtra, /**< */ ORI_ObjectType_RxEUtraFDD, /**< */ ORI_ObjectType_RxEUtraTDD, /**< */ ORI_ObjectType_RxGSM, /**< */ + ORI_ObjectType_RxNRFDD, /**< */ + ORI_ObjectType_RxNRTDD, /**< */ ORI_ObjectType_ORILink, /**< */ ORI_ObjectType_ExternalEventPort, /**< */ ORI_ObjectType_AISGPort, /**< */ @@ -223,6 +227,7 @@ typedef enum ORI_ObjectParam_SigPath_AWS_enableCompBitChange, /**< */ ORI_ObjectParam_SigPath_AWS_measuredPwr, /**< */ ORI_ObjectParam_SigPath_AWS_axcIncr, /**< */ + ORI_ObjectParam_SigPath_AWS_arfcn, /**< */ ORI_ObjectParam_TxSigPath_t2a, /**< */ ORI_ObjectParam_TxSigPath_maxTxPwr, /**< */ ORI_ObjectParam_TxSigPath_dlCalRE, /**< */ @@ -252,12 +257,12 @@ typedef enum ORI_ObjectParam_ORILink_AWS_localMAC, /**< */ ORI_ObjectParam_ORILink_AWS_remoteMAC, /**< */ ORI_ObjectParam_ORILink_AWS_t14, /**< */ + ORI_ObjectParam_ORILink_AWS_sfpTxPow, /**< */ + ORI_ObjectParam_ORILink_AWS_sfpRxPow, /**< */ ORI_ObjectParam_ORILink_AWS_remoteIP, /**< */ ORI_ObjectParam_ORILink_AWS_localIP, /**< */ ORI_ObjectParam_ORILink_AWS_remoteUdpPort, /**< */ ORI_ObjectParam_ORILink_AWS_localUdpPort, /**< */ - ORI_ObjectParam_ORILink_AWS_sfpTxPow, /**< */ - ORI_ObjectParam_ORILink_AWS_sfpRxPow, /**< */ ORI_ObjectParam_AISGPort_busPowerEnable, /**< */ ORI_ObjectParam_AISGALD_deviceType, /**< */ ORI_ObjectParam_AISGALD_UID, /**< */ @@ -1146,6 +1151,50 @@ typedef struct ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ } ORI_ObjectParams_TxSigPathGSM_s; +/** + * @struct ORI_ObjectParams_TxSigPathNRFDD_s + * @brief Structure containing the parameters of a TxSigPath NRFDD object. + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t dlCalREMax; /**< RO. Max possible buffer in RE for DL timing calibration in Tc/16.*/ + uint32_t t2a; /**< RO. RE time delay. */ + uint16_t dlCalRE; /**< RW-Locked. Time delay to enable DL timing calibration in Tc/16. */ + int16_t maxTxPwr; /**< RW. Max tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_TxSigPathNRFDD_s; + +/** + * @struct ORI_ObjectParams_TxSigPathNRTDD_s + * @brief Structure containing the parameters of a TxSigPath NRTDD object. + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t dlCalREMax; /**< RO. Max possible buffer in RE for DL timing calibration in Tc/16.*/ + uint32_t t2a; /**< RO. RE time delay. */ + uint16_t dlCalRE; /**< RW-Locked. Time delay to enable DL timing calibration in Tc/16. */ + int16_t maxTxPwr; /**< RW. Max tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_TxSigPathNRTDD_s; + /** * @struct ORI_ObjectParams_RxSigPathUtra_s * @brief Structure containing the parameters of a RxSigPath UTRAFDD object. @@ -1239,6 +1288,48 @@ typedef struct uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ } ORI_ObjectParams_RxSigPathGSM_s; +/** + * @struct ORI_ObjectParams_RxSigPathNRFDD_s + * @brief Structure containing the parameters of a RxSigPath NRFDD object. + * + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t ulCalREMax; /**< RO. Max possible buffer in RE for UL timing calibration in Tc/2.*/ + uint32_t ta3; /**< RO. RE time delay. */ + uint16_t ulCalRE; /**< RW-Locked. Time delay to enable UL timing calibration in Tc/2. */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Rx power for this path, unit is dBm/10 (e.g. -650 for -65 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_RxSigPathNRFDD_s; + +/** + * @struct ORI_ObjectParams_RxSigPathNRTDD_s + * @brief Structure containing the parameters of a RxSigPath NRTDD object. + * + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t ulCalREMax; /**< RO. Max possible buffer in RE for UL timing calibration in Tc/2.*/ + uint32_t ta3; /**< RO. RE time delay. */ + uint16_t ulCalRE; /**< RW-Locked. Time delay to enable UL timing calibration in Tc/2. */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Rx power for this path, unit is dBm/10 (e.g. -650 for -65 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_RxSigPathNRTDD_s; + /** * @struct ORI_ObjectParams_ORILink_s * @brief Structure containing the parameters of an ORI Link object. @@ -1258,12 +1349,12 @@ typedef struct uint8_t AWS_localMAC[6]; /**< R0. AW2S Vendor specific: Local MAC address of the ORI link. */ uint8_t AWS_remoteMAC[6]; /**< RW. AW2S Vendor specific: Remote MAC address of the ORI link. */ uint32_t AWS_t14; /**< RO. AW2S Vendor specific: CPRI time delay component. */ - uint8_t AWS_remoteIP[4]; /**< RW. AW2S Vendor specific: REC IP for ECPRI Ethernet frame */ - uint8_t AWS_localIP[4]; /**< R0. AW2S Vendor specific: RE IP for ECPRI Ethernet frame */ - uint16_t AWS_remoteUdpPort; /**< RW. AW2S Vendor specific: REC Udp Port for ECPRI Ethernet frame */ - uint16_t AWS_localUdpPort; /**< R0. AW2S Vendor specific: RE Udp Port for ECPRI Ethernet frame */ uint32_t AWS_sfpTxPow; /**< RO. AW2S Vendor specific: SFP Tx power. */ uint32_t AWS_sfpRxPow; /**< RO. AW2S Vendor specific: SFP Rx power. */ + uint8_t AWS_remoteIP[4]; /**< RW. AW2S Vendor specific: IP of REC for ECPRI Ethernet frame */ + uint8_t AWS_localIP[4]; /**< RW. AW2S Vendor specific: IP of RE for ECPRI Ethernet frame */ + uint16_t AWS_remoteUdpPort; /**< RW. AW2S Vendor specific: UDP port of REC for ECPRI Ethernet frame */ + uint16_t AWS_localUdpPort; /**< RO. AW2S Vendor specific: UDP port of RE for ECPRI Ethernet frame */ } ORI_ObjectParams_ORILink_s; /** @@ -1393,10 +1484,14 @@ typedef union ORI_ObjectParams_TxSigPathEUtraFDD_s TxEUtraFDD; /**< Parameters for ::ORI_ObjectType_TxEUtraFDD. */ ORI_ObjectParams_TxSigPathEUtraTDD_s TxEUtraTDD; /**< Parameters for ::ORI_ObjectType_TxEUtraTDD. */ ORI_ObjectParams_TxSigPathGSM_s TxGSM; /**< Parameters for ::ORI_ObjectType_TxGSM. */ + ORI_ObjectParams_TxSigPathNRFDD_s TxNRFDD; /**< Parameters for ::ORI_ObjectType_TxNRFDD. */ + ORI_ObjectParams_TxSigPathNRTDD_s TxNRTDD; /**< Parameters for ::ORI_ObjectType_TxNRTDD. */ ORI_ObjectParams_RxSigPathUtra_s RxUtra; /**< Parameters for ::ORI_ObjectType_RxUtra. */ ORI_ObjectParams_RxSigPathEUtraFDD_s RxEUtraFDD; /**< Parameters for ::ORI_ObjectType_RxEUtraFDD. */ ORI_ObjectParams_RxSigPathEUtraTDD_s RxEUtraTDD; /**< Parameters for ::ORI_ObjectType_RxEUtraTDD. */ ORI_ObjectParams_RxSigPathGSM_s RxGSM; /**< Parameters for ::ORI_ObjectType_RxGSM. */ + ORI_ObjectParams_RxSigPathNRFDD_s RxNRFDD; /**< Parameters for ::ORI_ObjectType_RxNRFDD. */ + ORI_ObjectParams_RxSigPathNRTDD_s RxNRTDD; /**< Parameters for ::ORI_ObjectType_RxNRTDD. */ ORI_ObjectParams_ORILink_s ORILink; /**< Parameters for ::ORI_ObjectType_ORILink. */ ORI_ObjectParams_ExternalEventPort_s ExternalEventPort; /**< Parameters for ::ORI_ObjectType_ExternalEventPort. */ ORI_ObjectParams_AISGPort_s AISGPort; /**< Parameters for ::ORI_ObjectType_AISGPort. */ From 2776ec78b05c0f5b57e13c0911660d4b9decfc2d Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 3 Mar 2022 17:21:59 +0100 Subject: [PATCH 36/84] Add initial support for DL Data Delivery status reporting over NR-User plane protocol in gtp-u --- openair3/ocp-gtpu/gtp_itf.cpp | 124 ++++++++++++++++++++++++++++++---- openair3/ocp-gtpu/gtp_itf.h | 5 ++ 2 files changed, 114 insertions(+), 15 deletions(-) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 421aa24cc0..36cd9c7df1 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -34,6 +34,22 @@ typedef struct Gtpv1uMsgHeader { teid_t teid; } __attribute__((packed)) Gtpv1uMsgHeaderT; +//TS 38.425, Figure 5.5.2.2-1 +typedef struct DlDataDeliveryStatus_flags { + uint8_t LPR:1; //Lost packet report + uint8_t FFI:1; //Final Frame Ind + uint8_t deliveredPdcpSn:1; //Highest Delivered NR PDCP SN Ind + uint8_t transmittedPdcpSn:1; //Highest Transmitted NR PDCP SN Ind + uint8_t pduType:4; //PDU type + uint8_t CR:1; //Cause Report + uint8_t deliveredReTxPdcpSn:1; //Delivered retransmitted NR PDCP SN Ind + uint8_t reTxPdcpSn:1; //Retransmitted NR PDCP SN Ind + uint8_t DRI:1; //Data Rate Indication + uint8_t deliveredPdcpSnRange:1; //Delivered NR PDCP SN Range Ind + uint8_t spare:3; + uint32_t drbBufferSize; //Desired buffer size for the data radio bearer +} __attribute__((packed)) DlDataDeliveryStatus_flagsT; + #pragma pack() // TS 29.060, table 7.1 defines the possible message types @@ -59,12 +75,14 @@ typedef struct ocp_gtpv1u_bearer_s { typedef struct { map bearers; + teid_t outgoing_teid; } teidData_t; typedef struct { rnti_t rnti; ebi_t incoming_rb_id; gtpCallback callBack; + teid_t outgoing_teid; } rntiData_t; class gtpEndPoint { @@ -109,14 +127,16 @@ instance_t legacyInstanceMapping=0; static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen, - bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) { - AssertFatal(extHdrFlag==false,"Not developped"); + bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType, + uint8_t *extensionHeader_buffer, uint8_t extensionHeader_length) { + LOG_D(GTPU, "Peer IP:%u peer port:%u outgoing teid:%u \n", peerIp, peerPort, teid); + //AssertFatal(extHdrFlag==false,"Not developped"); int headerAdditional=0; if ( seqNumFlag || npduNumFlag || extHdrFlag) headerAdditional=4; - int fullSize=GTPV1U_HEADER_SIZE+headerAdditional+msgLen; + int fullSize=GTPV1U_HEADER_SIZE+headerAdditional+msgLen+extensionHeader_length; uint8_t buffer[fullSize]; Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *)buffer ; // N should be 0 for us (it was used only in 2G and 3G) @@ -128,20 +148,42 @@ instance_t legacyInstanceMapping=0; msgHdr->PT=1; msgHdr->version=1; msgHdr->msgType=msgType; - msgHdr->msgLength=htons(msgLen); + msgHdr->msgLength=htons(msgLen+extensionHeader_length); if ( seqNumFlag || extHdrFlag || npduNumFlag) - msgHdr->msgLength+=4; + msgHdr->msgLength+=htons(4); msgHdr->teid=htonl(teid); if(seqNumFlag || extHdrFlag || npduNumFlag) { - *((uint16_t *) (buffer+8)) = seqNumFlag ? htons(seqNum) : 0x0000; - *((uint8_t *) (buffer+10)) = npduNumFlag ? htons(npduNum) : 0x00; - *((uint8_t *) (buffer+11)) = extHdrFlag ? htons(extHdrType) : 0x00; + *((uint16_t *) (buffer+8)) = seqNumFlag ? seqNum : 0x0000; + *((uint8_t *) (buffer+10)) = npduNumFlag ? npduNum : 0x00; + *((uint8_t *) (buffer+11)) = extHdrFlag ? extHdrType : 0x00; + + /**(buffer+8) = seqNumFlag ? htons(seqNum) : 0x0000; + *(buffer+10) = npduNumFlag ? htons(npduNum) : 0x00; + *(buffer+11) = extHdrFlag ? htons(extHdrType) : 0x00; + *(buffer+11) = extHdrType;*/ + } + + if(extHdrFlag){ + while (extHdrType){ + if (extensionHeader_length > 0 && extHdrType == 0x84){ + memcpy(buffer+GTPV1U_HEADER_SIZE+headerAdditional, extensionHeader_buffer, extensionHeader_length); + LOG_D(GTPU, "Extension Header for DDD added. The length is: %d, extension header type is: %x \n", extensionHeader_length, *((uint8_t *) (buffer+11))); + extHdrType = extensionHeader_buffer[extensionHeader_length -1]; + LOG_D(GTPU, "Next extension header type is: %x \n", *((uint8_t *) (buffer+11))); + } + else { + LOG_W(GTPU, "Extension header type not supported, returning... \n"); + return GTPNOK; + } + } + } + if (Msg!= NULL){ + memcpy(buffer+GTPV1U_HEADER_SIZE+headerAdditional+extensionHeader_length, Msg, msgLen); } - memcpy(buffer+GTPV1U_HEADER_SIZE+headerAdditional, Msg, msgLen); // Fix me: add IPv6 support, using flag ipVersion static struct sockaddr_in to= {0}; to.sin_family = AF_INET; @@ -196,9 +238,9 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b gtpv1uCreateAndSendMsg(compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, - GTP_GPDU, + GTP_GPDU, tmp.teid_outgoing, - buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ; + buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0, NULL, 0) ; } static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, bool seqNumFlag, bool npduNumFlag) { @@ -239,9 +281,9 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, gtpv1uCreateAndSendMsg(compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, - GTP_GPDU, + GTP_GPDU, tmp.teid_outgoing, - buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ; + buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0, NULL, 0) ; } static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req) { @@ -445,6 +487,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].outgoing_teid= outgoing_teid; + inst->te2ue_mapping[incoming_teid].callBack=callBack; ocp_gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id]; @@ -664,7 +708,7 @@ static int Gtpv1uHandleEchoReq(int h, return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid), recovery, sizeof recovery, - 1, 0, 0, seq, 0, 0); + 1, 0, 0, seq, 0, 0, NULL, 0); } @@ -787,9 +831,24 @@ static int Gtpv1uHandleGpdu(int h, if( msgHdr->E || msgHdr->S ||msgHdr->PN) offset+=4; + uint32_t NR_PDCP_PDU_SN = 0; //Consider the length of 1 or more extension headers that can be present in the GTP-U PDU if(msgHdr->E) { - while (msgBuf[offset]!=0) { + while (msgBuf[offset]!=0){ + if(msgBuf[offset-1] == 0x84){ //Extension header corresponding to NR-RAN container type + uint8_t PDU_type = (msgBuf[offset+1]>>4) & 0x0f; + if (PDU_type == 0){ //DL USER Data Format + if((msgBuf[offset+2]>>2)& 0x3){ //"Report delivered" and "User data existence flags" enabled (TS 38.425, 5.4) + /*Store the NR PDCP PDU SN for which a delivery status report shall be generated once the + *PDU gets forwarded to the lower layers*/ + NR_PDCP_PDU_SN = msgBuf[offset+3] << 16 | msgBuf[offset+4] << 8 | msgBuf[offset+5]; + LOG_D(GTPU, " NR_PDCP_PDU_SN: %u \n", NR_PDCP_PDU_SN); + } + } + else{ + LOG_W(GTPU, "NR-RAN container type: %d not supported \n", PDU_type); + } + } LOG_D(GTPU, "Extension header length in multiple of 4 bytes is: %d \n", msgBuf[offset]); offset+=msgBuf[offset]*4 -1; } @@ -830,6 +889,41 @@ static int Gtpv1uHandleGpdu(int h, &sourceL2Id, &destinationL2Id) ) LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); + if(NR_PDCP_PDU_SN > 0 && NR_PDCP_PDU_SN %5 ==0){ + LOG_D (GTPU, "Create and send DL DATA Delivery status for the previously received PDU, NR_PDCP_PDU_SN: %u \n", NR_PDCP_PDU_SN); + /*Total size of DDD_status PDU = 1 octet to report extension header length + * size of mandatory part + 3 octets for highest transmitted/delivered PDCP SN + * 1 octet for padding + 1 octet for next extension header type, + * according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/ + extensionHeader_t *extensionHeader; + extensionHeader = (extensionHeader_t *) calloc(1, sizeof(extensionHeader_t)) ; + extensionHeader->buffer[0] = (1+sizeof(DlDataDeliveryStatus_flagsT)+3+1+1)/4; + DlDataDeliveryStatus_flagsT DlDataDeliveryStatus; + DlDataDeliveryStatus.deliveredPdcpSn = 0; + DlDataDeliveryStatus.transmittedPdcpSn= 1; + DlDataDeliveryStatus.pduType = 1; + DlDataDeliveryStatus.drbBufferSize = htonl(1000000); //hardcoded for now but normally we should extract it from RLC + memcpy(extensionHeader->buffer+1, &DlDataDeliveryStatus, sizeof(DlDataDeliveryStatus_flagsT)); + uint8_t offset = sizeof(DlDataDeliveryStatus_flagsT)+1; + + extensionHeader->buffer[offset] = (NR_PDCP_PDU_SN >> 16) & 0xff; + extensionHeader->buffer[offset+1] = (NR_PDCP_PDU_SN >> 8) & 0xff; + extensionHeader->buffer[offset+2] = NR_PDCP_PDU_SN & 0xff; + LOG_D(GTPU, "Octets reporting NR_PDCP_PDU_SN, extensionHeader->buffer[offset]: %u, extensionHeader->buffer[offset+1]:%u, extensionHeader->buffer[offset+2]:%u \n", extensionHeader->buffer[offset], extensionHeader->buffer[offset+1],extensionHeader->buffer[offset+2]); + extensionHeader->buffer[offset+3] = 0x00; //Padding octet + extensionHeader->buffer[offset+4] = 0x00; //No more extension headers + /*Total size of DDD_status PDU = size of mandatory part + + * 3 octets for highest transmitted/delivered PDCP SN + + * 1 octet for padding + 1 octet for next extension header type, + * according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/ + extensionHeader->length = 1+sizeof(DlDataDeliveryStatus_flagsT)+3+1+1; + gtpv1uCreateAndSendMsg(h, + peerIp, + peerPort, + GTP_GPDU, + inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, + NULL, 0, false, false, true, 0, 0, 0x84, extensionHeader->buffer, extensionHeader->length) ; + } LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h, msgBufLen-offset, diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h index 3893acf40f..940e3415bf 100644 --- a/openair3/ocp-gtpu/gtp_itf.h +++ b/openair3/ocp-gtpu/gtp_itf.h @@ -41,6 +41,11 @@ typedef struct openAddr_s { instance_t originInstance; } openAddr_t; +typedef struct extensionHeader_s{ + uint8_t buffer[500]; + uint8_t length; +}extensionHeader_t; + // the init function create a gtp instance and return the gtp instance id // the parameter originInstance will be sent back in each message from gtp to the creator void ocp_gtpv1uReceiver(int h); From 14ec3e505d036d5bad87b16135412379637d2bda Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 9 Mar 2022 19:08:15 +0100 Subject: [PATCH 37/84] Fix decoding of UE-capabilities-RAT-container-list at the DU after receiving it from the CU --- openair2/RRC/NR/rrc_gNB.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 48987b6a97..97aed1ebee 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3004,9 +3004,9 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha if(req->cu_to_du_rrc_information!=NULL){ - /*if(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ + if(req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ LOG_I(NR_RRC, "Length of ue_CapabilityRAT_ContainerList is: %d \n", (int) req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); - struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList; + struct NR_UE_CapabilityRAT_ContainerList *ue_CapabilityRAT_ContainerList = NULL; asn_dec_rval_t dec_rval = uper_decode_complete( NULL, &asn_DEF_NR_UE_CapabilityRAT_ContainerList, (void **)&ue_CapabilityRAT_ContainerList, @@ -3088,7 +3088,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha //TODO } } - }*/ + } } NR_CellGroupConfig_t *cellGroupConfig; From a88a8dae8e12bf9ed2b55d8243e58ebe21304c69 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 11 Mar 2022 12:27:00 +0100 Subject: [PATCH 38/84] config of pucch2 in rrcsetup --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 09baf9d824..ac092957d1 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1034,6 +1034,8 @@ void fill_initial_SpCellConfig(int uid, pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL); + config_pucch_resset1(pucch_Config, NULL); + set_pucch_power_config(pucch_Config, carrier->do_CSIRS); initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; @@ -1410,11 +1412,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, if (SpCellConfig == NULL) return; - NR_BWP_UplinkDedicated_t *initialUplinkBWP = SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - NR_PUCCH_Config_t *pucch_Config = initialUplinkBWP->pucch_Config->choice.setup; - config_pucch_resset1(pucch_Config, uecap); - set_pucch_power_config(pucch_Config, carrier->do_CSIRS); - NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; From 03617b916545d08a862653b31c29c615469b324c Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 14 Mar 2022 10:43:59 +0100 Subject: [PATCH 39/84] more general SR config for period and offset --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- openair2/RRC/NR/nr_rrc_config.c | 53 ++++++++++++++++++++++++++--- openair2/RRC/NR/nr_rrc_config.h | 3 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index ac092957d1..2d09506c69 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1184,7 +1184,7 @@ void fill_initial_SpCellConfig(int uid, srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - schedulingrequest_config(cellGroupConfig->mac_CellGroupConfig, pucch_Config); + schedulingrequest_config(scc, cellGroupConfig->mac_CellGroupConfig, pucch_Config); set_dl_DataToUL_ACK(pucch_Config, carrier->minRXTXTIME); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 99786f660b..835348095e 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -286,7 +286,52 @@ void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs) { ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); } -void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, +void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, + NR_ServingCellConfigCommon_t *scc) { + + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + int sr_slot = 0; + if(tdd) + sr_slot = tdd->nrofDownlinkSlots; // SR in the first uplink slot + + schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); + + if(sr_slot<10){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = sr_slot; + return; + } + if(sr_slot<20){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl20 = sr_slot; + return; + } + if(sr_slot<40){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = sr_slot; + return; + } + if(sr_slot<80){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl80 = sr_slot; + return; + } + if(sr_slot<160){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl160 = sr_slot; + return; + } + if(sr_slot<320){ + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl320 = sr_slot; + return; + } + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl640 = sr_slot; +} + +void schedulingrequest_config(NR_ServingCellConfigCommon_t *scc, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config) { mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); @@ -306,9 +351,9 @@ void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); schedulingRequestResourceConfig->schedulingRequestResourceId = 1; schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; + + set_SR_periodandoffset(schedulingRequestResourceConfig, scc); + schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); *schedulingRequestResourceConfig->resource = *pucchressetid; ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 1080d58d40..813549b621 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -117,7 +117,8 @@ void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); -void schedulingrequest_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, +void schedulingrequest_config(NR_ServingCellConfigCommon_t *scc, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config); void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 46e6b46016..a9c0f523c5 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -859,7 +859,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); // <= 2 bits config_pucch_resset1(pucch_Config, uecap); // > 2 bits - schedulingrequest_config(secondaryCellGroup->mac_CellGroupConfig, pucch_Config); + schedulingrequest_config(servingcellconfigcommon, secondaryCellGroup->mac_CellGroupConfig, pucch_Config); pucch_Config->schedulingRequestResourceToReleaseList=NULL; pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; From 8edcd41a8d26ccb779a09c41ed05097ba6c951e6 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 14 Mar 2022 17:35:04 +0100 Subject: [PATCH 40/84] fix for pucch0 that straddles DC carrier --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index b85dbd1454..eab48fa24a 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -282,23 +282,35 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, } int n2; + int nb_re_pucch = 12*pucch_pdu->prb_size; // prb size is 1 + int32_t rp[frame_parms->nb_antennas_rx][2][nb_re_pucch],*tmp_rp; + for (int l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; + re_offset[l] = (12*prb_offset[l]) + frame_parms->first_carrier_offset; if (re_offset[l]>= frame_parms->ofdm_symbol_size) re_offset[l]-=frame_parms->ofdm_symbol_size; - - AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); - int16_t *r; + for (int aa=0;aanb_antennas_rx;aa++) { - r=(int16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; + tmp_rp = &rxdataF[aa][soffset + l2*frame_parms->ofdm_symbol_size]; + if(re_offset[l] + nb_re_pucch > frame_parms->ofdm_symbol_size) { + int neg_length = frame_parms->ofdm_symbol_size-re_offset[l]; + int pos_length = nb_re_pucch-neg_length; + memcpy1((void*)rp[aa][l],(void*)&tmp_rp[re_offset[l]],neg_length*sizeof(int32_t)); + memcpy1((void*)&rp[aa][l][neg_length],(void*)tmp_rp,pos_length*sizeof(int32_t)); + } + else + memcpy1((void*)rp[aa][l],(void*)&tmp_rp[re_offset[l]],nb_re_pucch*sizeof(int32_t)); + + int16_t *r = (int16_t*)&rp[aa][l]; n2=0; for (n=0;n<12;n++,n2+=2) { xr[aa][l][n2] +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15); xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); #ifdef DEBUG_NR_PUCCH_RX printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n", - x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]); + x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]); #endif } } @@ -395,9 +407,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01; int SNRtimes10,sigenergy=0; for (int aa=0;aanb_antennas_rx;aa++) - sigenergy += signal_energy_nodc(&rxdataF[aa][soffset+ - (pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size)+ - re_offset[0]],12); + sigenergy += signal_energy_nodc(rp[aa][0],12); SNRtimes10 = xrtmag_dBtimes10-(10*max_n0); int cqi; if (SNRtimes10 < -640) cqi=0; From f40b579a78bd1ccd886c10ee0ad147138855d10c Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 16 Mar 2022 15:13:50 +0100 Subject: [PATCH 41/84] fix for phy-simulator issues --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 4 ++-- openair1/SIMULATION/NR_PHY/pucchsim.c | 1 + openair2/RRC/NR/nr_rrc_config.c | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index eab48fa24a..083dbb328c 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -283,7 +283,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int n2; int nb_re_pucch = 12*pucch_pdu->prb_size; // prb size is 1 - int32_t rp[frame_parms->nb_antennas_rx][2][nb_re_pucch],*tmp_rp; + int32_t rp[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][nb_re_pucch],*tmp_rp; for (int l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; @@ -305,7 +305,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int16_t *r = (int16_t*)&rp[aa][l]; n2=0; - for (n=0;n<12;n++,n2+=2) { + for (n=0;n>15); xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); #ifdef DEBUG_NR_PUCCH_RX diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 151d51d726..5d85135677 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -640,6 +640,7 @@ int main(int argc, char **argv) pucch_pdu.initial_cyclic_shift = 0; pucch_pdu.start_symbol_index = startingSymbolIndex; pucch_pdu.prb_start = startingPRB; + pucch_pdu.prb_size = 1; pucch_pdu.bwp_start = 0; pucch_pdu.bwp_size = N_RB_DL; if (nrofSymbols>1) { diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 835348095e..98004f9add 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -37,6 +37,7 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, int rbsize, int mcs_table) { + NR_Phy_Parameters_t *phy_Parameters = &cap->phy_Parameters; int band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; NR_BandNR_t *nr_bandnr = CALLOC(1,sizeof(NR_BandNR_t)); nr_bandnr->bandNR = band; @@ -50,8 +51,8 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, *bandNRinfo->pdsch_256QAM_FR2 = NR_BandNR__pdsch_256QAM_FR2_supported; } else{ - cap->phy_Parameters.phy_ParametersFR1 = CALLOC(1,sizeof(*cap->phy_Parameters.phy_ParametersFR1)); - NR_Phy_ParametersFR1_t *phy_fr1 = cap->phy_Parameters.phy_ParametersFR1; + phy_Parameters->phy_ParametersFR1 = CALLOC(1,sizeof(*phy_Parameters->phy_ParametersFR1)); + NR_Phy_ParametersFR1_t *phy_fr1 = phy_Parameters->phy_ParametersFR1; phy_fr1->pdsch_256QAM_FR1 = CALLOC(1,sizeof(*phy_fr1->pdsch_256QAM_FR1)); *phy_fr1->pdsch_256QAM_FR1 = NR_Phy_ParametersFR1__pdsch_256QAM_FR1_supported; } @@ -73,6 +74,9 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, ASN_SEQUENCE_ADD(&fs->featureSetsDownlinkPerCC->list, fs_cc); } + + phy_Parameters->phy_ParametersFRX_Diff = CALLOC(1,sizeof(*phy_Parameters->phy_ParametersFRX_Diff)); + phy_Parameters->phy_ParametersFRX_Diff->pucch_F0_2WithoutFH = NULL; } void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){ From aba5098e30587309f8e5af9c66a8bdaba7e3cdb6 Mon Sep 17 00:00:00 2001 From: matzakos Date: Thu, 17 Mar 2022 17:01:01 +0100 Subject: [PATCH 42/84] Remove hardcoding of port numbers in handling of F1 UE context modification request --- openair2/F1AP/f1ap_du_ue_context_management.c | 4 +++- openair2/RRC/NR/rrc_gNB.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 30dec1de08..ca0ddcc82d 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -1154,6 +1154,8 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel; BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address); OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid); + // 3GPP assumes GTP-U is on port 2152, but OAI is configurable + drb_p->up_ul_tnl[0].port=getCxt(false,instance)->setupReq.CUport; switch (drbs_tobesetupmod_item_p->rLCMode) { case F1AP_RLCMode_rlc_am: @@ -1174,7 +1176,7 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, drb_p->drb_id, drb_p->up_ul_tnl[0].teid, addr, - 2152, + drb_p->up_ul_tnl[0].port, lteDURecvCb); drb_p->up_dl_tnl_length++; } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 28ccfb1181..bded0a619d 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3465,7 +3465,7 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co drb_p.drb_id, drb_p.up_ul_tnl[0].teid, addr, - 2152, + drb_p.up_ul_tnl[0].port, DURecvCb); } } From 4e73ef0c3bb6a949e9498e8b03e9a8a33c4f93aa Mon Sep 17 00:00:00 2001 From: matzakos Date: Thu, 17 Mar 2022 17:01:50 +0100 Subject: [PATCH 43/84] Avoid exiting in case of PDPC receiving UL user-plane traffic before the DRB is established -Happened occasionally in the CU/DU split scenario --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 1f66400af1..8afba9d315 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -274,9 +274,10 @@ static void do_pdcp_data_ind( if (rb != NULL) { 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", + LOG_E(PDCP, "%s:%d:%s: no RB found (rb_id %ld, srb_flag %d)\n", __FILE__, __LINE__, __FUNCTION__, rb_id, srb_flagP); - exit(1); + return; + } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); From a77c1d32026f4f4b8a9c0a54d8a7a0f87cf4ef84 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 29 Mar 2022 12:17:37 +0200 Subject: [PATCH 44/84] Trigger first DL Data Delivery status from DU to report the buffer availability to the CU -After that no DL traffic is getting blocked at the Accelleran CU for low values of throughput -Remaining to remove the hardcoded value of buffer availability and report the actual value from the DU. --- openair2/COMMON/gtpv1_u_messages_def.h | 3 +- openair2/COMMON/gtpv1_u_messages_types.h | 8 +++ openair2/RRC/NR/rrc_gNB.c | 15 +++++ openair3/ocp-gtpu/gtp_itf.cpp | 74 ++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) diff --git a/openair2/COMMON/gtpv1_u_messages_def.h b/openair2/COMMON/gtpv1_u_messages_def.h index 44e9d4fbdf..e0e5db5b7f 100644 --- a/openair2/COMMON/gtpv1_u_messages_def.h +++ b/openair2/COMMON/gtpv1_u_messages_def.h @@ -27,4 +27,5 @@ MESSAGE_DEF(GTPV1U_ENB_END_MARKER_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_end MESSAGE_DEF(GTPV1U_ENB_END_MARKER_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_ind_t, Gtpv1uEndMarkerInd) MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq) -MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq) +MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq) +MESSAGE_DEF(GTPV1U_DU_BUFFER_REPORT_REQ, MESSAGE_PRIORITY_MED, gtpv1u_DU_buffer_report_req_t, NRGtpv1uBufferReportReq) diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h index 096f0f4697..4111b00024 100644 --- a/openair2/COMMON/gtpv1_u_messages_types.h +++ b/openair2/COMMON/gtpv1_u_messages_types.h @@ -39,6 +39,8 @@ #define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq +#define GTPV1U_DU_BUFFER_REPORT_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uBufferReportReq + #define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF typedef struct gtpv1u_enb_create_x2u_tunnel_req_s { @@ -213,4 +215,10 @@ typedef struct gtpv1u_gnb_tunnel_data_req_s { pdusessionid_t pdusession_id; } gtpv1u_gnb_tunnel_data_req_t; +typedef struct gtpv1u_DU_buffer_report_req_s { + uint32_t buffer_availability; + rnti_t rnti; + pdusessionid_t pdusession_id; +} gtpv1u_DU_buffer_report_req_t; + #endif /* GTPV1_U_MESSAGES_TYPES_H_ */ diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index f7a53c59a4..d7ff9492a5 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3487,6 +3487,21 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co } else if(req->ReconfigComplOutcome == RRCreconf_success){ LOG_I(NR_RRC, "CU reporting RRC Reconfiguration success \n"); + if(ue_context_p->ue_context.DRB_configList!=NULL){ + LOG_I(NR_RRC, "Send first DDD buffer status reporting towards the CU through an ITTI message to gtp-u \n"); + uint8_t drb_id = ue_context_p->ue_context.DRB_configList->list.array[0]->drb_Identity; + rnti_t rnti = ue_context_p->ue_context.rnti; + LOG_I(NR_RRC, "Reported in DDD drb_id:%d, rnti:%d\n", drb_id, rnti); + MessageDef *msg = itti_alloc_new_message_sized(TASK_RRC_GNB, 0, GTPV1U_DU_BUFFER_REPORT_REQ, + sizeof(gtpv1u_gnb_tunnel_data_req_t)); + gtpv1u_DU_buffer_report_req_t *req=>PV1U_DU_BUFFER_REPORT_REQ(msg); + req->pdusession_id = drb_id; + req->rnti = rnti; + req->buffer_availability = 1000000; //Hardcoding to be removed and read the actual RLC buffer availability instead + extern instance_t DUuniqInstance; + itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg); + + } } /* Fill the UE context setup response ITTI message to send to F1AP */ diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index c79f7ecce2..20db486561 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -286,6 +286,74 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0, NULL, 0) ; } +static void fillDlDeliveryStatusReport(extensionHeader_t *extensionHeader, uint32_t RLC_buffer_availability, uint32_t NR_PDCP_PDU_SN){ + + extensionHeader->buffer[0] = (1+sizeof(DlDataDeliveryStatus_flagsT)+(NR_PDCP_PDU_SN>0?3:0)+(NR_PDCP_PDU_SN>0?1:0)+1)/4; + DlDataDeliveryStatus_flagsT DlDataDeliveryStatus; + DlDataDeliveryStatus.deliveredPdcpSn = 0; + DlDataDeliveryStatus.transmittedPdcpSn= NR_PDCP_PDU_SN>0?1:0; + DlDataDeliveryStatus.pduType = 1; + DlDataDeliveryStatus.drbBufferSize = htonl(RLC_buffer_availability); + memcpy(extensionHeader->buffer+1, &DlDataDeliveryStatus, sizeof(DlDataDeliveryStatus_flagsT)); + uint8_t offset = sizeof(DlDataDeliveryStatus_flagsT)+1; + + if(NR_PDCP_PDU_SN>0){ + extensionHeader->buffer[offset] = (NR_PDCP_PDU_SN >> 16) & 0xff; + extensionHeader->buffer[offset+1] = (NR_PDCP_PDU_SN >> 8) & 0xff; + extensionHeader->buffer[offset+2] = NR_PDCP_PDU_SN & 0xff; + LOG_D(GTPU, "Octets reporting NR_PDCP_PDU_SN, extensionHeader->buffer[offset]: %u, extensionHeader->buffer[offset+1]:%u, extensionHeader->buffer[offset+2]:%u \n", extensionHeader->buffer[offset], extensionHeader->buffer[offset+1],extensionHeader->buffer[offset+2]); + extensionHeader->buffer[offset+3] = 0x00; //Padding octet + offset = offset+3; + } + extensionHeader->buffer[offset] = 0x00; //No more extension headers + /*Total size of DDD_status PDU = size of mandatory part + + * 3 octets for highest transmitted/delivered PDCP SN + + * 1 octet for padding + 1 octet for next extension header type, + * according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/ + extensionHeader->length = 1+sizeof(DlDataDeliveryStatus_flagsT)+ + (NR_PDCP_PDU_SN>0?3:0)+ + (NR_PDCP_PDU_SN>0?1:0)+1; +} + +static void gtpv1uSendDlDeliveryStatus(instance_t instance, gtpv1u_DU_buffer_report_req_t *req){ + rnti_t rnti=req->rnti; + int rab_id=req->pdusession_id; + pthread_mutex_lock(&globGtp.gtp_lock); + auto inst=&globGtp.instances[compatInst(instance)]; + auto ptrRnti=inst->ue2te_mapping.find(rnti); + + if ( ptrRnti==inst->ue2te_mapping.end() ) { + LOG_E(GTPU, "[%ld] GTP-U gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); + pthread_mutex_unlock(&globGtp.gtp_lock); + return; + } + + map::iterator ptr2=ptrRnti->second.bearers.find(rab_id); + + if ( ptr2 == ptrRnti->second.bearers.end() ) { + LOG_D(GTPU,"GTP-U instance: %ld sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id); + pthread_mutex_unlock(&globGtp.gtp_lock); + return; + } + + extensionHeader_t *extensionHeader; + extensionHeader = (extensionHeader_t *) calloc(1, sizeof(extensionHeader_t)); + fillDlDeliveryStatusReport(extensionHeader, req->buffer_availability,0); + + LOG_I(GTPU,"[%ld] GTP-U sending DL Data Delivery status to RNTI:RAB:teid %x/%x/%x, oldseq %d, oldnum %d\n", + instance, rnti, rab_id,ptr2->second.teid_outgoing, ptr2->second.seqNum,ptr2->second.npduNum ); + // copy to release the mutex + gtpv1u_bearer_t tmp=ptr2->second; + pthread_mutex_unlock(&globGtp.gtp_lock); + gtpv1uCreateAndSendMsg(compatInst(instance), + tmp.outgoing_ip_addr, + tmp.outgoing_port, + GTP_GPDU, + tmp.teid_outgoing, + NULL, 0, false, false, true, 0, 0, 0x84, extensionHeader->buffer, extensionHeader->length) ; + +} + static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req) { rnti_t rnti=req->rnti; int rab_id=req->rab_id; @@ -1049,6 +1117,12 @@ void *gtpv1uTask(void *args) { } break; + case GTPV1U_DU_BUFFER_REPORT_REQ:{ + gtpv1uSendDlDeliveryStatus(compatInst(ITTI_MSG_DESTINATION_INSTANCE(message_p)), + >PV1U_DU_BUFFER_REPORT_REQ(message_p)); + } + break; + case TERMINATE_MESSAGE: break; From 4c17c9c62a834ae6795ad5c013ff9dee654153cb Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 3 Apr 2022 18:15:17 +0200 Subject: [PATCH 45/84] change SR slot in FDD to avoid assertion --- openair2/RRC/NR/nr_rrc_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 98004f9add..9ee9d2a5bc 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -294,7 +294,7 @@ void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequ NR_ServingCellConfigCommon_t *scc) { const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - int sr_slot = 0; + int sr_slot = 1; // in FDD SR in slot 1 if(tdd) sr_slot = tdd->nrofDownlinkSlots; // SR in the first uplink slot From 0eb2acb00bea1f3be14b3cc0f4696b66ac36c504 Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 6 Apr 2022 10:43:09 +0200 Subject: [PATCH 46/84] F1 code cleanup before merge -Remove commented out code, debug logs, some hardcodings, fix indentation --- openair2/COMMON/f1ap_messages_types.h | 38 +- openair2/F1AP/f1ap_cu_ue_context_management.c | 571 +++++++++--------- openair2/F1AP/f1ap_du_interface_management.c | 28 +- openair2/F1AP/f1ap_du_ue_context_management.c | 129 ++-- openair2/GNB_APP/gnb_config.c | 7 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 4 - openair2/RRC/NR/rrc_gNB.c | 89 +-- openair2/RRC/NR/rrc_gNB_NGAP.c | 47 +- openair2/RRC/NR_UE/rrc_UE.c | 4 +- openair3/ocp-gtpu/gtp_itf.cpp | 6 - 10 files changed, 416 insertions(+), 507 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 409e4a912e..4a0d3eb411 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -352,6 +352,15 @@ typedef struct cu_to_du_rrc_information_s { uint8_t measConfig_length; }cu_to_du_rrc_information_t; +typedef struct du_to_du_rrc_information_s { + uint8_t * cellGroupConfig; + uint8_t cellGroupConfig_length; + uint8_t * measGapConfig; + uint8_t measGapConfig_length; + uint8_t * requestedP_MaxFR1; + uint8_t requestedP_MaxFR1_length; +}du_to_cu_rrc_information_t; + typedef enum QoS_information_e { NG_RAN_QoS = 0, EUTRAN_QoS = 1, @@ -377,10 +386,13 @@ typedef struct f1ap_ue_context_setup_s { uint32_t servCellId; cu_to_du_rrc_information_t *cu_to_du_rrc_information; uint8_t cu_to_du_rrc_information_length; - uint8_t *du_to_cu_rrc_information; - uint8_t du_to_cu_rrc_information_length; - f1ap_drb_to_be_setup_t *drbs_to_be_setup; // BK: need to replace by s1ap_initial_context_setup_req - uint8_t drbs_to_be_setup_length; // BK: need to replace by s1ap_initial_context_setup_req + //uint8_t *du_to_cu_rrc_information; + du_to_cu_rrc_information_t *du_to_cu_rrc_information; + uint32_t du_to_cu_rrc_information_length; + f1ap_drb_to_be_setup_t *drbs_to_be_setup; + uint8_t drbs_to_be_setup_length; + f1ap_drb_to_be_setup_t *drbs_to_be_modified; + uint8_t drbs_to_be_modified_length; QoS_information_t QoS_information_type; uint8_t drbs_failed_to_be_setup_length; f1ap_rb_failed_to_be_setup_t *drbs_failed_to_be_setup; @@ -388,29 +400,11 @@ typedef struct f1ap_ue_context_setup_s { uint8_t srbs_to_be_setup_length; uint8_t srbs_failed_to_be_setup_length; f1ap_rb_failed_to_be_setup_t *srbs_failed_to_be_setup; - s1ap_initial_context_setup_req_t *s1ap_initial_context_setup_req; ReconfigurationCompl_t ReconfigComplOutcome; - // coniatner for the rrc_eNB_generate_SecurityModeCommand message uint8_t *rrc_container; int rrc_container_length; } f1ap_ue_context_setup_t; -typedef struct f1ap_ue_context_setup_resp_s { - uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti - uint32_t gNB_DU_ue_id; - uint16_t rnti; - uint8_t du_to_cu_rrc_information[1024 /*Arbitrarily big enough*/]; - uint32_t du_to_cu_rrc_information_length; - f1ap_drb_to_be_setup_t *drbs_setup; // BK: need to replace by s1ap_initial_context_setup_req - uint8_t drbs_setup_length; // BK: need to replace by s1ap_initial_context_setup_req - f1ap_srb_to_be_setup_t *srbs_setup; - uint8_t srbs_setup_length; - uint8_t srbs_failed_to_be_setup_length; - f1ap_rb_failed_to_be_setup_t *srbs_failed_to_be_setup; - uint8_t drbs_failed_to_be_setup_length; - f1ap_rb_failed_to_be_setup_t *drbs_failed_to_be_setup; -} f1ap_ue_context_setup_resp_t; - typedef enum F1ap_Cause_e { F1AP_CAUSE_NOTHING, /* No components present */ F1AP_CAUSE_RADIO_NETWORK, diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 037be0c8d4..08d0ff042e 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -135,23 +135,23 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* optional */ /* 6.1 cG_ConfigInfo */ if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->cG_ConfigInfo!=NULL){ - const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.cG_ConfigInfo, cG_ConfigInfo); - OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen(cG_ConfigInfoStr)) ; + OCTET_STRING_fromBuf(cG_ConfigInfo, (const char *)f1ap_ue_context_setup_req->cu_to_du_rrc_information->cG_ConfigInfo, + f1ap_ue_context_setup_req->cu_to_du_rrc_information->cG_ConfigInfo_length); } /* optional */ /* 6.2 uE_CapabilityRAT_ContainerList */ if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList!=NULL){ asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, (const char *)f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList, - f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); + f1ap_ue_context_setup_req->cu_to_du_rrc_information->uE_CapabilityRAT_ContainerList_length); } /* optional */ /* 6.3 measConfig */ if(f1ap_ue_context_setup_req->cu_to_du_rrc_information->measConfig!=NULL){ - const char measConfigStr[]="asdsa1d32sa1d31asd31as"; asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.measConfig, measConfig); - OCTET_STRING_fromBuf(measConfig, measConfigStr, strlen(measConfigStr)) ; + OCTET_STRING_fromBuf(measConfig, (const char*)f1ap_ue_context_setup_req->cu_to_du_rrc_information->measConfig, + f1ap_ue_context_setup_req->cu_to_du_rrc_information->measConfig_length); } } @@ -248,201 +248,95 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* mandatory */ /* c11. SRBs_ToBeSetup_List */ if(f1ap_ue_context_setup_req->srbs_to_be_setup_length > 0){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie11); - ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List; - ie11->criticality = F1AP_Criticality_reject; // ? - ie11->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SRBs_ToBeSetup_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List; + ie11->criticality = F1AP_Criticality_reject; // ? + ie11->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SRBs_ToBeSetup_List; - for (int i=0; isrbs_to_be_setup_length; i++) { - // - asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetup_List.list, F1AP_SRBs_ToBeSetup_ItemIEs_t, srbs_toBeSetup_item_ies); - srbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_Item; // 73 - srbs_toBeSetup_item_ies->criticality = F1AP_Criticality_ignore; - srbs_toBeSetup_item_ies->value.present = F1AP_SRBs_ToBeSetup_ItemIEs__value_PR_SRBs_ToBeSetup_Item; - /* 11.1 SRBs_ToBeSetup_Item */ - F1AP_SRBs_ToBeSetup_Item_t *srbs_toBeSetup_item=&srbs_toBeSetup_item_ies->value.choice.SRBs_ToBeSetup_Item; - /* 11.1.1 sRBID */ - srbs_toBeSetup_item->sRBID = f1ap_ue_context_setup_req->srbs_to_be_setup[i].srb_id; - /* OPTIONAL */ - /* 11.1.2 duplicationIndication */ - //if (0) { - asn1cCallocOne(srbs_toBeSetup_item->duplicationIndication, + for (int i=0; isrbs_to_be_setup_length; i++) { + asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetup_List.list, F1AP_SRBs_ToBeSetup_ItemIEs_t, srbs_toBeSetup_item_ies); + srbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_Item; // 73 + srbs_toBeSetup_item_ies->criticality = F1AP_Criticality_ignore; + srbs_toBeSetup_item_ies->value.present = F1AP_SRBs_ToBeSetup_ItemIEs__value_PR_SRBs_ToBeSetup_Item; + /* 11.1 SRBs_ToBeSetup_Item */ + F1AP_SRBs_ToBeSetup_Item_t *srbs_toBeSetup_item=&srbs_toBeSetup_item_ies->value.choice.SRBs_ToBeSetup_Item; + /* 11.1.1 sRBID */ + srbs_toBeSetup_item->sRBID = f1ap_ue_context_setup_req->srbs_to_be_setup[i].srb_id; + /* OPTIONAL */ + /* 11.1.2 duplicationIndication */ + asn1cCallocOne(srbs_toBeSetup_item->duplicationIndication, F1AP_DuplicationIndication_true); // enum - //} - } + } } /* mandatory */ /* c12. DRBs_ToBeSetup_List */ if(f1ap_ue_context_setup_req->drbs_to_be_setup_length){ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie12); - ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List; - ie12->criticality = F1AP_Criticality_reject; - ie12->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRBs_ToBeSetup_List; - LOG_I(F1AP, "Length of drbs_to_be_setup: %d \n", f1ap_ue_context_setup_req->drbs_to_be_setup_length); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List; + ie12->criticality = F1AP_Criticality_reject; + ie12->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRBs_ToBeSetup_List; + LOG_I(F1AP, "Length of drbs_to_be_setup: %d \n", f1ap_ue_context_setup_req->drbs_to_be_setup_length); - for (int i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; i++) { - // - asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetup_List.list, F1AP_DRBs_ToBeSetup_ItemIEs_t, drbs_toBeSetup_item_ies); - drbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_Item; - drbs_toBeSetup_item_ies->criticality = F1AP_Criticality_reject; - drbs_toBeSetup_item_ies->value.present = F1AP_DRBs_ToBeSetup_ItemIEs__value_PR_DRBs_ToBeSetup_Item; - /* 12.1 DRBs_ToBeSetup_Item */ - F1AP_DRBs_ToBeSetup_Item_t *drbs_toBeSetup_item=&drbs_toBeSetup_item_ies->value.choice.DRBs_ToBeSetup_Item; - /* 12.1.1 dRBID */ - drbs_toBeSetup_item->dRBID = f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id; // 9 - /* 12.1.2 qoSInformation */ - int some_decide_qos = 0; // BK: Need Check + for (int i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; i++) { + // + asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetup_List.list, F1AP_DRBs_ToBeSetup_ItemIEs_t, drbs_toBeSetup_item_ies); + drbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_Item; + drbs_toBeSetup_item_ies->criticality = F1AP_Criticality_reject; + drbs_toBeSetup_item_ies->value.present = F1AP_DRBs_ToBeSetup_ItemIEs__value_PR_DRBs_ToBeSetup_Item; + /* 12.1 DRBs_ToBeSetup_Item */ + F1AP_DRBs_ToBeSetup_Item_t *drbs_toBeSetup_item=&drbs_toBeSetup_item_ies->value.choice.DRBs_ToBeSetup_Item; + /* 12.1.1 dRBID */ + drbs_toBeSetup_item->dRBID = f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id; // 9 + /* 12.1.2 qoSInformation */ + int some_decide_qos = 0; // BK: Need Check - if (some_decide_qos) { - drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; - /* 12.1.2.1 eUTRANQoS */ - asn1cCalloc(drbs_toBeSetup_item->qoSInformation.choice.eUTRANQoS, eUTRANQoS); - /* 12.1.2.1.1 qCI */ - eUTRANQoS->qCI = 254L; - /* 12.1.2.1.2 allocationAndRetentionPriority */ - { - /* 12.1.2.1.2.1 priorityLevel */ - eUTRANQoS->allocationAndRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - /* 12.1.2.1.2.2 pre_emptionCapability */ - eUTRANQoS->allocationAndRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_may_trigger_pre_emption; // enum - /* 12.1.2.1.2.2 pre_emptionVulnerability */ - eUTRANQoS->allocationAndRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum - } - - /* OPTIONAL */ - /* 12.1.2.1.3 gbrQosInformation */ - if (0) { - eUTRANQoS->gbrQosInformation = (F1AP_GBR_QosInformation_t *)calloc(1, sizeof(F1AP_GBR_QosInformation_t)); - asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateDL, 1L); - asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateUL, 1L); - asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateDL, 1L); - asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateUL, 1L); - } - } else { - /* 12.1.2 DRB_Information */ - drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; - F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); - ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; - F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; - drbs_toBeSetup_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; - /* 12.1.2.1 dRB_QoS */ - { - /* qoS_Characteristics */ + if (some_decide_qos) { + drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; + /* 12.1.2.1 eUTRANQoS */ + asn1cCalloc(drbs_toBeSetup_item->qoSInformation.choice.eUTRANQoS, eUTRANQoS); + /* 12.1.2.1.1 qCI */ + eUTRANQoS->qCI = 254L; + /* 12.1.2.1.2 allocationAndRetentionPriority */ { - int some_decide_qoS_characteristics = 0; // BK: Need Check - - if (some_decide_qoS_characteristics) { - DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); - } else { - DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); - /* qoSPriorityLevel */ - tmp->qoSPriorityLevel = 1L; - /* packetDelayBudget */ - tmp->packetDelayBudget = 1L; - /* packetErrorRate */ - tmp->packetErrorRate.pER_Scalar = 1L; - tmp->packetErrorRate.pER_Exponent = 6L; - - /* OPTIONAL */ - /* delayCritical */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); - } - - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); - } - - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); - } - } // if some_decide_qoS_characteristics - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ - { - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum - } // nGRANallocationRetentionPriority - - /* OPTIONAL */ - /* gBR_QoS_Flow_Information */ - if (0) { - asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); - asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); - asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); - - /* OPTIONAL */ - /* maxPacketLossRateDownlink */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); - } - - /* OPTIONAL */ - /* maxPacketLossRateUplink */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); - } + /* 12.1.2.1.2.1 priorityLevel */ + eUTRANQoS->allocationAndRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + /* 12.1.2.1.2.2 pre_emptionCapability */ + eUTRANQoS->allocationAndRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_may_trigger_pre_emption; // enum + /* 12.1.2.1.2.2 pre_emptionVulnerability */ + eUTRANQoS->allocationAndRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum } /* OPTIONAL */ - /* reflective_QoS_Attribute */ + /* 12.1.2.1.3 gbrQosInformation */ if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); + eUTRANQoS->gbrQosInformation = (F1AP_GBR_QosInformation_t *)calloc(1, sizeof(F1AP_GBR_QosInformation_t)); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateDL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateUL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateDL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateUL, 1L); } - } // dRB_QoS - /* 12.1.2.2 sNSSAI */ - { - /* sST */ - OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); - - /* OPTIONAL */ - /* sD */ - if (0) { - asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - } - } - - /* OPTIONAL */ - /* 12.1.2.3 notificationControl */ - if (0) { - asn1cCallocOne(DRB_Information->notificationControl, - F1AP_NotificationControl_active); // enum - } - - /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy - - for (int k = 0; k < 1; k ++) { - asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, - F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); - /* qoSFlowIndicator */ - flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; - /* qoSFlowLevelQoSParameters */ + } else { + /* 12.1.2 DRB_Information */ + drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; + F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); + ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; + F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; + drbs_toBeSetup_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; + /* 12.1.2.1 dRB_QoS */ { /* qoS_Characteristics */ { int some_decide_qoS_characteristics = 0; // BK: Need Check - F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; if (some_decide_qoS_characteristics) { - QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - setQos(QosParams->choice.non_Dynamic_5QI); + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); } else { - QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); /* qoSPriorityLevel */ tmp->qoSPriorityLevel = 1L; /* packetDelayBudget */ @@ -454,36 +348,33 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* OPTIONAL */ /* delayCritical */ if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); - *tmp = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); } /* OPTIONAL */ /* averagingWindow */ if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); - *tmp = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); } /* OPTIONAL */ /* maxDataBurstVolume */ if (0) { - asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); - *tmp= 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); } } // if some_decide_qoS_characteristics } // qoS_Characteristics /* nGRANallocationRetentionPriority */ { - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum } // nGRANallocationRetentionPriority /* OPTIONAL */ /* gBR_QoS_Flow_Information */ if (0) { - asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); + asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); @@ -492,81 +383,187 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, /* OPTIONAL */ /* maxPacketLossRateDownlink */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); } /* OPTIONAL */ /* maxPacketLossRateUplink */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); } } /* OPTIONAL */ /* reflective_QoS_Attribute */ if (0) { - asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); + asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); } - } // qoSFlowLevelQoSParameters - } - } // if some_decide_qos + } // dRB_QoS + /* 12.1.2.2 sNSSAI */ + { + /* sST */ + OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); - /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ - for (int j = 0; j < f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { - /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ - transport_layer_addr_t addr; - int sz=sizeof(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); - memcpy(addr.buffer,&f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); - addr.length = sz*8; - f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= - newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, - f1ap_ue_context_setup_req->rnti, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, - 0xFFFF, // We will set the right value from DU answer - addr, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].port, - cu_f1u_data_req); - /* 12.3.1 ULTunnels_ToBeSetup_Item */ - asn1cSequenceAdd(drbs_toBeSetup_item->uLUPTNLInformation_ToBeSetup_List.list, - F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, - gTPTunnel); - /* 12.3.1.1.1 transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, + /* OPTIONAL */ + /* sD */ + if (0) { + asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", + strlen("asdsa1d32sa1d31asd31as")); + } + } + + /* OPTIONAL */ + /* 12.1.2.3 notificationControl */ + if (0) { + asn1cCallocOne(DRB_Information->notificationControl, + F1AP_NotificationControl_active); // enum + } + + /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy + + for (int k = 0; k < 1; k ++) { + asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, + F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); + /* qoSFlowIndicator */ + flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; + /* qoSFlowLevelQoSParameters */ + { + /* qoS_Characteristics */ + { + int some_decide_qoS_characteristics = 0; // BK: Need Check + F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; + + if (some_decide_qoS_characteristics) { + QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(QosParams->choice.non_Dynamic_5QI); + } else { + QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; + + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); + *tmp = 1L; + } + + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); + *tmp= 1L; + } + } // if some_decide_qoS_characteristics + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority + + /* OPTIONAL */ + /* gBR_QoS_Flow_Information */ + if (0) { + asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); + + /* OPTIONAL */ + /* maxPacketLossRateDownlink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); + } + + /* OPTIONAL */ + /* maxPacketLossRateUplink */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); + } + } + + /* OPTIONAL */ + /* reflective_QoS_Attribute */ + if (0) { + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); + } + } // qoSFlowLevelQoSParameters + } + } // if some_decide_qos + + /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ + for (int j = 0; j < f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { + /*Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU*/ + transport_layer_addr_t addr; + int sz=sizeof(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); + memcpy(addr.buffer,&f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); + addr.length = sz*8; + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= + newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_setup_req->rnti, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + 0xFFFF, // We will set the right value from DU answer + addr, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].port, + cu_f1u_data_req); + /* 12.3.1 ULTunnels_ToBeSetup_Item */ + asn1cSequenceAdd(drbs_toBeSetup_item->uLUPTNLInformation_ToBeSetup_List.list, + F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + gTPTunnel); + /* 12.3.1.1.1 transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, &gTPTunnel->transportLayerAddress); - /* 12.3.1.1.2 gTP_TEID */ - INT32_TO_OCTET_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, - &gTPTunnel->gTP_TEID); - } + /* 12.3.1.1.2 gTP_TEID */ + INT32_TO_OCTET_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, + &gTPTunnel->gTP_TEID); + } - /* 12.1.4 rLCMode */ - /* TODO use rlc_mode from f1ap_drb_to_be_setup */ - switch (f1ap_ue_context_setup_req->drbs_to_be_setup[i].rlc_mode) { - case RLC_MODE_AM: - drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_am; - break; + /* 12.1.4 rLCMode */ + /* TODO use rlc_mode from f1ap_drb_to_be_setup */ + switch (f1ap_ue_context_setup_req->drbs_to_be_setup[i].rlc_mode) { + case RLC_MODE_AM: + drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_am; + break; - default: - drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; - } + default: + drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; + } - /* OPTIONAL */ - /* 12.1.5 ULConfiguration */ - if (0) { - asn1cCalloc(drbs_toBeSetup_item->uLConfiguration, tmp); - tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; - } + /* OPTIONAL */ + /* 12.1.5 ULConfiguration */ + if (0) { + asn1cCalloc(drbs_toBeSetup_item->uLConfiguration, tmp); + tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; + } - /* OPTIONAL */ - /* 12.1.6 duplicationActivation */ - if (0) { - asn1cCalloc(drbs_toBeSetup_item->duplicationActivation, tmp); - *tmp = F1AP_DuplicationActivation_active; // enum + /* OPTIONAL */ + /* 12.1.6 duplicationActivation */ + if (0) { + asn1cCalloc(drbs_toBeSetup_item->duplicationActivation, tmp); + *tmp = F1AP_DuplicationActivation_active; // enum + } } } - } /* OPTIONAL */ /* InactivityMonitoringRequest */ @@ -673,9 +670,10 @@ int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, return -1; } - f1ap_ue_context_setup_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - memcpy(f1ap_ue_context_setup_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - f1ap_ue_context_setup_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + f1ap_ue_context_setup_resp->du_to_cu_rrc_information = (du_to_cu_rrc_information_t *)calloc(1,sizeof(du_to_cu_rrc_information_t)); + f1ap_ue_context_setup_resp->du_to_cu_rrc_information->cellGroupConfig = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + memcpy(f1ap_ue_context_setup_resp->du_to_cu_rrc_information->cellGroupConfig, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_setup_resp->du_to_cu_rrc_information->cellGroupConfig_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; // DRBs_Setup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_DRBs_Setup_List, false); @@ -1143,7 +1141,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context /* optional */ /* c7. RRCRconfigurationCompleteIndicator */ - if (0) { + if (f1ap_ue_context_modification_req->ReconfigComplOutcome == RRCreconf_success) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie71); ie71->id = F1AP_ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator; ie71->criticality = F1AP_Criticality_ignore; @@ -1153,13 +1151,13 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context /* optional */ /* c8. RRCContainer */ - if (0) { + if (f1ap_ue_context_modification_req->rrc_container != NULL) { asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie81); ie81->id = F1AP_ProtocolIE_ID_id_RRCContainer; ie81->criticality = F1AP_Criticality_ignore; ie81->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie81->value.choice.RRCContainer, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + OCTET_STRING_fromBuf(&ie81->value.choice.RRCContainer, f1ap_ue_context_modification_req->rrc_container, + f1ap_ue_context_modification_req->rrc_container_length); } /* optional */ @@ -1232,10 +1230,8 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context srbs_toBeSetupMod_item->sRBID = f1ap_ue_context_modification_req->srbs_to_be_setup[i].srb_id; /* OPTIONAL */ /* 11.1.2 duplicationIndication */ - //if (0) { asn1cCallocOne(srbs_toBeSetupMod_item->duplicationIndication, F1AP_DuplicationIndication_true); // enum - //} } } @@ -1310,42 +1306,42 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); } else { - DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); - /* qoSPriorityLevel */ - tmp->qoSPriorityLevel = 1L; - /* packetDelayBudget */ - tmp->packetDelayBudget = 1L; - /* packetErrorRate */ - tmp->packetErrorRate.pER_Scalar = 1L; - tmp->packetErrorRate.pER_Exponent = 6L; + DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); + /* qoSPriorityLevel */ + tmp->qoSPriorityLevel = 1L; + /* packetDelayBudget */ + tmp->packetDelayBudget = 1L; + /* packetErrorRate */ + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; - /* OPTIONAL */ - /* delayCritical */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); - } + /* OPTIONAL */ + /* delayCritical */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); + } - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); - } + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); + } - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); - } - } // if some_decide_qoS_characteristics + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); + } + } // if some_decide_qoS_characteristics - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ - { - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum - } // nGRANallocationRetentionPriority + } // qoS_Characteristics + /* nGRANallocationRetentionPriority */ + { + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + } // nGRANallocationRetentionPriority /* OPTIONAL */ /* gBR_QoS_Flow_Information */ @@ -1682,10 +1678,11 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextModificationResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, false); if(ie!=NULL){ - f1ap_ue_context_modification_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_modification_resp->du_to_cu_rrc_information = (du_to_cu_rrc_information_t *)calloc(1, sizeof(du_to_cu_rrc_information_t)); + f1ap_ue_context_modification_resp->du_to_cu_rrc_information->cellGroupConfig = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - memcpy(f1ap_ue_context_modification_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); - f1ap_ue_context_modification_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + memcpy(f1ap_ue_context_modification_resp->du_to_cu_rrc_information->cellGroupConfig, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_modification_resp->du_to_cu_rrc_information->cellGroupConfig_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; } // DRBs_SetupMod_List diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index e972a31301..b48c576c75 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -172,25 +172,19 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { MCC_MNC_TO_PLMNID(cell->mcc, cell->mnc, cell->mnc_digit_length, &servedPLMN_item->pLMN_Identity); // // /* - CHOICE NR-MODE-Info */ F1AP_NR_Mode_Info_t *nR_Mode_Info= &served_cell_information->nR_Mode_Info; - //if(0){ - //F1AP_ProtocolExtensionContainer_154P260_t *p_154P260=calloc(1, sizeof(* p_154P260)); - F1AP_ProtocolExtensionContainer_154P34_t *p_154P34=calloc(1,sizeof(* p_154P34)); - servedPLMN_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p_154P34; - asn1cSequenceAdd(p_154P34->list, F1AP_ServedPLMNs_ItemExtIEs_t , served_plmns_itemExtIEs); - served_plmns_itemExtIEs->criticality = F1AP_Criticality_ignore; - served_plmns_itemExtIEs->id = F1AP_ProtocolIE_ID_id_TAISliceSupportList; - served_plmns_itemExtIEs->extensionValue.present = F1AP_ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList; - F1AP_SliceSupportList_t *slice_support_list = &served_plmns_itemExtIEs->extensionValue.choice.SliceSupportList; + F1AP_ProtocolExtensionContainer_154P34_t *p_154P34=calloc(1,sizeof(* p_154P34)); + servedPLMN_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p_154P34; + asn1cSequenceAdd(p_154P34->list, F1AP_ServedPLMNs_ItemExtIEs_t , served_plmns_itemExtIEs); + served_plmns_itemExtIEs->criticality = F1AP_Criticality_ignore; + served_plmns_itemExtIEs->id = F1AP_ProtocolIE_ID_id_TAISliceSupportList; + served_plmns_itemExtIEs->extensionValue.present = F1AP_ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList; + F1AP_SliceSupportList_t *slice_support_list = &served_plmns_itemExtIEs->extensionValue.choice.SliceSupportList; - asn1cSequenceAdd(slice_support_list->list, F1AP_SliceSupportItem_t, SliceSupport_item); - INT8_TO_OCTET_STRING(1,&SliceSupport_item->sNSSAI.sST); - //OCTET_STRING_fromBuf(&SliceSupport_item->sNSSAI.sST, "1", 1); - asn1cCalloc(SliceSupport_item->sNSSAI.sD, tmp); - INT24_TO_OCTET_STRING(1,tmp); - //OCTET_STRING_fromBuf(tmp, "1",1); - //} + asn1cSequenceAdd(slice_support_list->list, F1AP_SliceSupportItem_t, SliceSupport_item); + INT8_TO_OCTET_STRING(1,&SliceSupport_item->sNSSAI.sST); + asn1cCalloc(SliceSupport_item->sNSSAI.sD, tmp); + INT24_TO_OCTET_STRING(1,tmp); - if (f1ap_req(false, instance)->fdd_flag) { // FDD nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD; asn1cCalloc(nR_Mode_Info->choice.fDD, fDD_Info); diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index ca0ddcc82d..ce99a31dd3 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -280,27 +280,30 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* mandatory */ /* c3. DUtoCURRCInformation */ - asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3); - ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; - ie3->criticality = F1AP_Criticality_reject; - ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; - { - /* cellGroupConfig */ - OCTET_STRING_fromBuf(&ie3->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information, - resp->du_to_cu_rrc_information_length); + if(resp->du_to_cu_rrc_information){ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; + if(resp->du_to_cu_rrc_information->cellGroupConfig!=NULL){ + /* cellGroupConfig */ + OCTET_STRING_fromBuf(&ie3->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information->cellGroupConfig, + resp->du_to_cu_rrc_information->cellGroupConfig_length); + } /* OPTIONAL */ /* measGapConfig */ - if (0) { - asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.measGapConfig, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); + if (resp->du_to_cu_rrc_information->measGapConfig!=NULL) { + OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.measGapConfig, resp->du_to_cu_rrc_information->measGapConfig, + resp->du_to_cu_rrc_information->measGapConfig_length); } /* OPTIONAL */ /* requestedP_MaxFR1 */ - if (0) { + if (resp->du_to_cu_rrc_information->requestedP_MaxFR1!=NULL) { asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); + OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1, + resp->du_to_cu_rrc_information->requestedP_MaxFR1_length); } } @@ -676,14 +679,14 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, protocol_ctxt_t ctxt; DevAssert(pdu); container = &pdu->choice.initiatingMessage->value.choice.UEContextReleaseCommand; - // GNB_CU_UE_F1AP_ID + // GNB_CU_UE_F1AP_ID F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); ctxt.rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID); ctxt.instance = instance; ctxt.module_id = instance; ctxt.enb_flag = 1; - // GNB_DU_UE_F1AP_ID + // GNB_DU_UE_F1AP_ID F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); const rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, @@ -711,13 +714,13 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, } } - // We don't need the Cause - // Optional RRC Container: if present, send to UE + // We don't need the Cause + // Optional RRC Container: if present, send to UE F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_RRCContainer, false); if (ie && !UE_out_of_sync) { - // RRC message and UE is reachable, send message + // RRC message and UE is reachable, send message const sdu_size_t sdu_len = ie->value.choice.RRCContainer.size; mem_block_t *pdu_p = NULL; pdu_p = get_free_mem_block(sdu_len, __func__); @@ -769,7 +772,7 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, if (ue_context_p && !UE_out_of_sync) { // UE exists and is in sync so we start a timer before releasing the - // connection + // connection pthread_mutex_lock(&rrc_release_freelist); for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { @@ -793,13 +796,13 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, pthread_mutex_unlock(&rrc_release_freelist); ue_context_p->ue_context.ue_release_timer_s1 = 0; } else if (ue_context_p && UE_out_of_sync) { - // UE exists and is out of sync, drop the connection + // UE exists and is out of sync, drop the connection mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti); } else { LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti); } - // TODO send this once the connection has really been released + // TODO send this once the connection has really been released f1ap_ue_context_release_cplt_t cplt; cplt.rnti = ctxt.rnti; DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); @@ -1210,11 +1213,9 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context_modification_req->rrc_container = malloc(ieRRC->value.choice.RRCContainer.size); memcpy(f1ap_ue_context_modification_req->rrc_container, ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); - // AssertFatal(0, "check configuration, send to appropriate handler\n"); protocol_ctxt_t ctxt; // decode RRC Container and act on the message type - //FIXME - //rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + ctxt.rnti = f1ap_ue_context_modification_req->rnti; ctxt.instance = instance; ctxt.module_id = instance; ctxt.enb_flag = 1; @@ -1223,10 +1224,10 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p); } else { - LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n"); + LOG_E(F1AP, " RRCContainer in UEContextModificationRequestIEs size id 0\n"); } } else { - LOG_W(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); + LOG_W(F1AP, "can't find RRCContainer in UEContextModificationRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); } itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); @@ -1273,32 +1274,34 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex strlen("asdsa1d32sa1d31asd31as")); } - /* mandatory */ + /* optional */ /* c4. DUtoCURRCInformation */ + if(resp->du_to_cu_rrc_information!=NULL){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie4); ie4->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; ie4->criticality = F1AP_Criticality_reject; ie4->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation; - { + if(resp->du_to_cu_rrc_information->cellGroupConfig!=NULL){ /* cellGroupConfig */ - OCTET_STRING_fromBuf(&ie4->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information, - resp->du_to_cu_rrc_information_length); - - /* OPTIONAL */ - /* measGapConfig */ - if (0) { - asn1cCalloc(ie4->value.choice.DUtoCURRCInformation.measGapConfig, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); - } - - /* OPTIONAL */ - /* requestedP_MaxFR1 */ - if (0) { - asn1cCalloc(ie4->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); - OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); - } + OCTET_STRING_fromBuf(&ie4->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)resp->du_to_cu_rrc_information->cellGroupConfig, + resp->du_to_cu_rrc_information->cellGroupConfig_length); } + /* OPTIONAL */ + /* measGapConfig */ + if (resp->du_to_cu_rrc_information->measGapConfig!=NULL) { + OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.measGapConfig, resp->du_to_cu_rrc_information->measGapConfig, + resp->du_to_cu_rrc_information->measGapConfig_length); + } + + /* OPTIONAL */ + /* requestedP_MaxFR1 */ + if (resp->du_to_cu_rrc_information->requestedP_MaxFR1!=NULL) { + OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1, + resp->du_to_cu_rrc_information->requestedP_MaxFR1_length); + } + } + /* optional */ /* c5. DRBs_Setup_List */ @@ -1318,11 +1321,6 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* dRBID */ drbs_setupmod_item->dRBID = resp->drbs_to_be_setup[i].drb_id; - /* OPTIONAL */ - /* lCID */ - //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); - //drbs_setup_item.lCID = 1L; - for (int j=0; jdrbs_to_be_setup[i].up_dl_tnl_length; j++) { /* ADD */ asn1cSequenceAdd(drbs_setupmod_item->dLUPTNLInformation_ToBeSetup_List.list, @@ -1344,47 +1342,52 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* optional */ /* c6. DRBs_Modified_List */ - if(0){ + if(resp->drbs_to_be_modified_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie6); ie6->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; - ie6->criticality = F1AP_Criticality_reject; + ie6->criticality = F1AP_Criticality_ignore; ie6->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_Modified_List; - for (int i=0; i<1; i++) { + for (int i=0; idrbs_to_be_modified_length; i++) { asn1cSequenceAdd(ie6->value.choice.DRBs_Modified_List.list, F1AP_DRBs_Modified_ItemIEs_t, drbs_modified_item_ies); drbs_modified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_Item; - drbs_modified_item_ies->criticality = F1AP_Criticality_reject; + drbs_modified_item_ies->criticality = F1AP_Criticality_ignore; drbs_modified_item_ies->value.present = F1AP_DRBs_Modified_ItemIEs__value_PR_DRBs_Modified_Item; /* DRBs_modified_Item */ F1AP_DRBs_Modified_Item_t *drbs_modified_item= &drbs_modified_item_ies->value.choice.DRBs_Modified_Item; /* dRBID */ - drbs_modified_item->dRBID = 25L; + drbs_modified_item->dRBID = resp->drbs_to_be_modified[i].drb_id; /* ULTunnels_Modified_List */ int maxnoofULTunnels = 1; // 2; - for (int j=0; jdrbs_to_be_modified[i].up_dl_tnl_length; j++) { /* DLTunnels_Modified_Item */ asn1cSequenceAdd(drbs_modified_item->dLUPTNLInformation_ToBeSetup_List.list, F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item, tmp); tmp->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, gTPTunnel); - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); + /* transportLayerAddress */ + struct sockaddr_in addr= {0}; + inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, + &addr.sin_addr.s_addr); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + INT32_TO_OCTET_STRING(resp->drbs_to_be_modified[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); } } } /* optional */ /* c7. SRBs_FailedToBeSetupMod_List */ - if(0){ + if(resp->srbs_failed_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie7); ie7->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; ie7->criticality = F1AP_Criticality_reject; ie7->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_FailedToBeSetupMod_List; - for (int i=0; i<1; i++) { + for (int i=0; isrbs_to_be_setup_length; i++) { asn1cSequenceAdd(ie7->value.choice.SRBs_FailedToBeSetupMod_List.list, F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t, srbs_failedToBeSetupMod_item_ies); srbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_Item; @@ -1394,7 +1397,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex F1AP_SRBs_FailedToBeSetupMod_Item_t *srbs_failedToBeSetupMod_item= &srbs_failedToBeSetupMod_item_ies->value.choice.SRBs_FailedToBeSetupMod_Item; /* - sRBID */ - srbs_failedToBeSetupMod_item->sRBID = 50L; + srbs_failedToBeSetupMod_item->sRBID = resp->srbs_failed_to_be_setup[i].rb_id; asn1cCalloc(srbs_failedToBeSetupMod_item->cause, tmp) tmp->present = F1AP_Cause_PR_radioNetwork; tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; @@ -1403,13 +1406,13 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* optional */ /* c8. DRBs_FailedToBeSetupMod_List */ - if(0){ + if(resp->drbs_failed_to_be_setup_length > 0){ asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie8); ie8->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; ie8->criticality = F1AP_Criticality_reject; ie8->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeSetupMod_List; - for (int i=0; i<1; i++) { + for (int i=0; idrbs_failed_to_be_setup_length; i++) { asn1cSequenceAdd(ie8->value.choice.DRBs_FailedToBeSetupMod_List.list, F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t, drbs_failedToBeSetupMod_item_ies); drbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_Item; @@ -1419,7 +1422,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex F1AP_DRBs_FailedToBeSetupMod_Item_t *drbs_failedToBeSetupMod_item= &drbs_failedToBeSetupMod_item_ies->value.choice.DRBs_FailedToBeSetupMod_Item; /* dRBID */ - drbs_failedToBeSetupMod_item->dRBID = 30L; + drbs_failedToBeSetupMod_item->dRBID = resp->drbs_failed_to_be_setup[i].rb_id; drbs_failedToBeSetupMod_item->cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); drbs_failedToBeSetupMod_item->cause->present = F1AP_Cause_PR_radioNetwork; drbs_failedToBeSetupMod_item->cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 42b23da09d..1dac3178da 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1879,11 +1879,7 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { f1Setup->ranac[k] = 0; f1Setup->mib[k] = rrc->carrier.MIB; f1Setup->mib_length[k] = rrc->carrier.sizeof_MIB; - if(0){ - f1Setup->sib1[k] = rrc->carrier.SIB1; - f1Setup->sib1_length[k] = rrc->carrier.sizeof_SIB1; - } - else{ + NR_BCCH_DL_SCH_Message_t *bcch_message = NULL; asn_dec_rval_t dec_rval = uper_decode_complete( NULL, @@ -1914,7 +1910,6 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { xer_fprint(stdout, &asn_DEF_NR_SIB1,(void *)bcch_message->message.choice.c1->choice.systemInformationBlockType1 ); //} f1Setup->sib1_length[k] = (enc_rval.encoded+7)/8; - } break; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 84099a58e6..79f1fcfdbe 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -992,10 +992,6 @@ void nr_schedule_ue_spec(module_id_t module_id, return; /* PREPROCESSOR */ - //Following commented section condition should be removed before update with develop. - /*if(slot!= 1 && slot!=11){ - return; - }*/ gNB_mac->pre_processor_dl(module_id, frame, slot); const int CC_id = 0; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index bded0a619d..97cc60d31c 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1388,49 +1388,6 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } - /*else if(SRB_configList!=NULL || DRB_configList!=NULL){ - MessageDef *message_p; - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ); - f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); - req->gNB_CU_ue_id = 0; - req->gNB_DU_ue_id = 0; - req->rnti = ue_context_pP->ue_context.rnti; - req->mcc = rrc->configuration.mcc[0]; - req->mnc = rrc->configuration.mnc[0]; - req->mnc_digit_length = rrc->configuration.mnc_digit_length[0]; - req->nr_cellid = rrc->nr_cellid; - if(SRB_configList!=NULL){ - req->srbs_to_be_setup = malloc(SRB_configList->list.count*sizeof(f1ap_srb_to_be_setup_t)); - req->srbs_to_be_setup_length = SRB_configList->list.count; - f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; - for (int i = 0; i < SRB_configList->list.count; i++){ - if(SRB_configList->list.array[i]->srb_Identity > 1){ - SRBs[i].srb_id = SRB_configList->list.array[i]->srb_Identity; - SRBs[i].lcid = SRB_configList->list.array[i]->srb_Identity; - } - } - } - if(DRB_configList!=NULL){ - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; - memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); - req->drbs_to_be_setup = malloc(DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t)); - req->drbs_to_be_setup_length = DRB_configList->list.count; - f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; - LOG_I(RRC, "Length of DRB list:%d, %d \n", DRB_configList->list.count, req->drbs_to_be_setup_length); - for (int i = 0; i < DRB_configList->list.count; i++){ - DRBs[i].drb_id = DRB_configList->list.array[i]->drb_Identity; - DRBs[i].rlc_mode = RLC_MODE_AM; - DRBs[i].up_ul_tnl[0].tl_address = inet_addr(rrc->eth_params_s.my_addr); - DRBs[i].up_ul_tnl[0].port=rrc->eth_params_s.my_portd; - DRBs[i].up_ul_tnl_length = 1; - DRBs[i].up_dl_tnl[0].tl_address = inet_addr(rrc->eth_params_s.remote_addr); - DRBs[i].up_dl_tnl[0].port=rrc->eth_params_s.remote_portd; - DRBs[i].up_dl_tnl_length = 1; - } - LOG_I(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n"); - } - itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); - }*/ #endif /* Set the SRB active in UE context */ @@ -2840,9 +2797,6 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { memset(mib->message.choice.mib,0,sizeof(struct NR_MIB)); memcpy(mib->message.choice.mib, mib_DU->message.choice.mib, sizeof(struct NR_MIB)); - /*rrc->carrier.SIB1 = malloc(f1_setup_req->sib1_length[i]); - rrc->carrier.sizeof_SIB1 = f1_setup_req->sib1_length[i]; - memcpy((void *)rrc->carrier.SIB1,f1_setup_req->sib1[i],f1_setup_req->sib1_length[i]);*/ dec_rval = uper_decode_complete(NULL, &asn_DEF_NR_SIB1, //&asn_DEF_NR_BCCH_DL_SCH_Message, (void **)&rrc->carrier.siblock1_DU, @@ -2860,12 +2814,6 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { xer_fprint(stdout, &asn_DEF_NR_SIB1,(void *)rrc->carrier.sib1); } - /*NR_BCCH_DL_SCH_Message_t *bcch_message = rrc->carrier.siblock1_DU; - AssertFatal(bcch_message->message.present == NR_BCCH_DL_SCH_MessageType_PR_c1, - "bcch_message->message.present != NR_BCCH_DL_SCH_MessageType_PR_c1\n"); - AssertFatal(bcch_message->message.choice.c1->present == NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1, - "bcch_message->message.choice.c1->present != NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1\n"); - rrc->carrier.sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1;*/ rrc->carrier.physCellId = f1_setup_req->cell[i].nr_pci; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).gNB_CU_name = rrc->node_name; @@ -3387,20 +3335,20 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context setup request at the DU\n"); } /* fixme: - * Here we should be encoding the updates on cellgroupconfig. Currently the content of - * celGroupConfig is empty because update_cellGroupConfig() function that is previously called is empty. + * Here we should be encoding the updates on cellgroupconfig based on the content of UE capabilities */ - resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); + resp->du_to_cu_rrc_information = calloc(1, sizeof(du_to_cu_rrc_information_t)); + resp->du_to_cu_rrc_information->cellGroupConfig = calloc(1,1024); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, ue_context_p->ue_context.masterCellGroup, //(void *)cellGroupConfig, - resp->du_to_cu_rrc_information, + resp->du_to_cu_rrc_information->cellGroupConfig, 1024); if (enc_rval.encoded == -1) { LOG_E(F1AP,"Could not encode ue_context.masterCellGroup, failed element %s\n",enc_rval.failed_type->name); exit(-1); } - resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; + resp->du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded+7)>>3; free(cellGroupConfig); itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); } @@ -3520,13 +3468,14 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co } //if(cellGroupConfig != NULL) { - resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); + resp->du_to_cu_rrc_information = calloc(1,sizeof(du_to_cu_rrc_information_t)); + resp->du_to_cu_rrc_information->cellGroupConfig = calloc(1,1024); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, ue_context_p->ue_context.masterCellGroup, //(void *)cellGroupConfig, - resp->du_to_cu_rrc_information, + resp->du_to_cu_rrc_information->cellGroupConfig, 1024); - resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; + resp->du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded+7)>>3; //} itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); } @@ -3546,8 +3495,8 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch asn_dec_rval_t dec_rval = uper_decode_complete( NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cellGroupConfig, - (uint8_t *)resp->du_to_cu_rrc_information, - (int) resp->du_to_cu_rrc_information_length); + (uint8_t *)resp->du_to_cu_rrc_information->cellGroupConfig, + (int) resp->du_to_cu_rrc_information->cellGroupConfig_length); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { AssertFatal(1==0,"Cell group config decode error\n"); @@ -3601,12 +3550,12 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, c struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt.rnti); NR_CellGroupConfig_t *cellGroupConfig = NULL; - if(resp->du_to_cu_rrc_information!=NULL){ + if(resp->du_to_cu_rrc_information->cellGroupConfig!=NULL){ asn_dec_rval_t dec_rval = uper_decode_complete( NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cellGroupConfig, - (uint8_t *)resp->du_to_cu_rrc_information, - (int) resp->du_to_cu_rrc_information_length); + (uint8_t *)resp->du_to_cu_rrc_information->cellGroupConfig, + (int) resp->du_to_cu_rrc_information->cellGroupConfig_length); if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { AssertFatal(1==0,"Cell group config decode error\n"); @@ -3619,15 +3568,7 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, c if(ue_context_p->ue_context.masterCellGroup == NULL){ ue_context_p->ue_context.masterCellGroup = calloc(1, sizeof(NR_CellGroupConfig_t)); } - /*if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ - if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ - LOG_I(NR_RRC, "rlc_BearerToAddModList not empty before filling it \n"); - free(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList); - } - ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, - sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - }*/ + if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ int ue_ctxt_rlc_Bearers = ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList->list.count; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 20e60eedb0..79e1f1f4ce 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1058,39 +1058,34 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( MessageDef *message_p; message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_MODIFICATION_REQ); f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_MODIFICATION_REQ (message_p); - //UE_IDs will be extracted from F1AP layer - req->gNB_CU_ue_id = 0; - req->gNB_DU_ue_id = 0; req->rnti = ue_context_p->ue_context.rnti; req->mcc = RC.nrrrc[ctxt.module_id]->configuration.mcc[0]; req->mnc = RC.nrrrc[ctxt.module_id]->configuration.mnc[0]; req->mnc_digit_length = RC.nrrrc[ctxt.module_id]->configuration.mnc_digit_length[0]; req->nr_cellid = RC.nrrrc[ctxt.module_id]->nr_cellid; - //if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { - /*Instruction towards the DU for SRB2 configuration*/ - req->srbs_to_be_setup = malloc(1*sizeof(f1ap_srb_to_be_setup_t)); - req->srbs_to_be_setup_length = 1; - f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; - SRBs[0].srb_id = 2; - SRBs[0].lcid = 2; + /*Instruction towards the DU for SRB2 configuration*/ + req->srbs_to_be_setup = malloc(1*sizeof(f1ap_srb_to_be_setup_t)); + req->srbs_to_be_setup_length = 1; + f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; + SRBs[0].srb_id = 2; + SRBs[0].lcid = 2; - /*Instruction towards the DU for DRB configuration and tunnel creation*/ - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; - memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); - req->drbs_to_be_setup = malloc(1*sizeof(f1ap_drb_to_be_setup_t)); - req->drbs_to_be_setup_length = 1; - f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; - LOG_I(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length); - DRBs[0].drb_id = 1; - DRBs[0].rlc_mode = RLC_MODE_AM; - DRBs[0].up_ul_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.my_addr); - DRBs[0].up_ul_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.my_portd; - DRBs[0].up_ul_tnl_length = 1; - DRBs[0].up_dl_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.remote_addr); - DRBs[0].up_dl_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.remote_portd; - DRBs[0].up_dl_tnl_length = 1; - //} + /*Instruction towards the DU for DRB configuration and tunnel creation*/ + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; + memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); + req->drbs_to_be_setup = malloc(1*sizeof(f1ap_drb_to_be_setup_t)); + req->drbs_to_be_setup_length = 1; + f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; + LOG_D(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length); + DRBs[0].drb_id = 1; + DRBs[0].rlc_mode = RLC_MODE_AM; + DRBs[0].up_ul_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.my_addr); + DRBs[0].up_ul_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.my_portd; + DRBs[0].up_ul_tnl_length = 1; + DRBs[0].up_dl_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.remote_addr); + DRBs[0].up_dl_tnl[0].port=RC.nrrrc[ctxt.module_id]->eth_params_s.remote_portd; + DRBs[0].up_dl_tnl_length = 1; itti_send_msg_to_task (TASK_CU_F1, ctxt.module_id, message_p); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 739bad594e..fa1690e450 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2699,9 +2699,9 @@ nr_rrc_ue_process_ueCapabilityEnquiry( AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - //} + } LOG_I(NR_RRC, "UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #ifdef ITTI_SIM diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 856597cb0e..08d1f5be64 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -815,12 +815,6 @@ static int Gtpv1uHandleGpdu(int h, return GTPNOK; } - /*int offset=8; - - if( msgHdr->E || msgHdr->S ||msgHdr->PN) - offset+=8;*/ - - //Minimum length of GTP-U header if non of the optional fields are present int offset= sizeof(Gtpv1uMsgHeaderT); From 693d687d3fdba898ab544f059f76fef55c13e55b Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 6 Apr 2022 10:57:36 +0200 Subject: [PATCH 47/84] Restore nr_l1_helpers.h and dependencies --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h | 27 ++++++++++++++++++++ openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b5265767ee..ddddcd09e2 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -50,7 +50,7 @@ #include "executables/softmodem-common.h" #include "executables/nr-uesoftmodem.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -//#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" //#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED diff --git a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c index be5c103a84..2d704b5c81 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c @@ -35,7 +35,7 @@ #include "mac_defs.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -//#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" #include "NR_P-Max.h" // Implementation of 6.2.4 Configured ransmitted power diff --git a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h new file mode 100644 index 0000000000..3bfeb29e2e --- /dev/null +++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.h @@ -0,0 +1,27 @@ +/* + * 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 + */ + +/** \brief Function to compute configured maximum output power according to clause 6.2.4 of 3GPP TS 38.101-1 version 16.5.0 Release 16 + @param Mod_id Module id of UE +*/ +long nr_get_Pcmax(module_id_t mod_id); +/** @}*/ + diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 4d303f0507..3851ee011d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -41,7 +41,7 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -//#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" +#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h" #include From 596282403856f723ff3396ba527b912e3299adc6 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 7 Apr 2022 16:34:16 +0200 Subject: [PATCH 48/84] Integrate true reporting of buffer availability of RLC(DU) towards the CU --- openair2/F1AP/f1ap_du_task.c | 2 +- openair2/F1AP/f1ap_itti_messaging.c | 2 +- openair2/LAYER2/nr_rlc/nr_rlc_entity.c | 51 ++++++++++++----------- openair2/LAYER2/nr_rlc/nr_rlc_entity.h | 2 + openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c | 6 +++ openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h | 1 + openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c | 6 +++ openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.h | 1 + openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c | 6 +++ openair2/LAYER2/nr_rlc/nr_rlc_entity_um.h | 1 + openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 34 ++++++++++++++- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h | 6 ++- openair2/RRC/NR/rrc_gNB.c | 2 +- openair3/ocp-gtpu/gtp_itf.cpp | 5 ++- 14 files changed, 94 insertions(+), 31 deletions(-) diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 24a1c44697..4982f7617b 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -175,7 +175,7 @@ void *F1AP_DU_task(void *arg) { break; case F1AP_UL_RRC_MESSAGE: // to rrc - LOG_I(F1AP, "DU Task Received F1AP_UL_RRC_MESSAGE\n"); + LOG_D(F1AP, "DU Task Received F1AP_UL_RRC_MESSAGE\n"); if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { DU_send_UL_NR_RRC_MESSAGE_TRANSFER(myInstance, diff --git a/openair2/F1AP/f1ap_itti_messaging.c b/openair2/F1AP/f1ap_itti_messaging.c index 21096a6518..e45edcc3a3 100644 --- a/openair2/F1AP/f1ap_itti_messaging.c +++ b/openair2/F1AP/f1ap_itti_messaging.c @@ -32,7 +32,7 @@ void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffe sctp_data_req->buffer = buffer; sctp_data_req->buffer_length = buffer_length; sctp_data_req->stream = stream; - LOG_I(F1AP, "Sending ITTI message to SCTP Task\n"); + LOG_D(F1AP, "Sending ITTI message to SCTP Task\n"); itti_send_msg_to_task(TASK_SCTP, instance, message_p); } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c index fefe2fc77d..1883bbdd6c 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c @@ -77,14 +77,15 @@ nr_rlc_entity_t *new_nr_rlc_entity_am( ret->sn_modulus = 1 << ret->sn_field_length; ret->window_size = ret->sn_modulus / 2; - ret->common.recv_pdu = nr_rlc_entity_am_recv_pdu; - ret->common.buffer_status = nr_rlc_entity_am_buffer_status; - ret->common.generate_pdu = nr_rlc_entity_am_generate_pdu; - ret->common.recv_sdu = nr_rlc_entity_am_recv_sdu; - ret->common.set_time = nr_rlc_entity_am_set_time; - ret->common.discard_sdu = nr_rlc_entity_am_discard_sdu; - ret->common.reestablishment = nr_rlc_entity_am_reestablishment; - ret->common.delete = nr_rlc_entity_am_delete; + ret->common.recv_pdu = nr_rlc_entity_am_recv_pdu; + ret->common.buffer_status = nr_rlc_entity_am_buffer_status; + ret->common.generate_pdu = nr_rlc_entity_am_generate_pdu; + ret->common.recv_sdu = nr_rlc_entity_am_recv_sdu; + ret->common.set_time = nr_rlc_entity_am_set_time; + ret->common.discard_sdu = nr_rlc_entity_am_discard_sdu; + ret->common.reestablishment = nr_rlc_entity_am_reestablishment; + ret->common.delete = nr_rlc_entity_am_delete; + ret->common.available_tx_space = nr_rlc_entity_am_available_tx_space; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; @@ -127,14 +128,15 @@ nr_rlc_entity_t *new_nr_rlc_entity_um( ret->sn_modulus = 1 << ret->sn_field_length; ret->window_size = ret->sn_modulus / 2; - ret->common.recv_pdu = nr_rlc_entity_um_recv_pdu; - ret->common.buffer_status = nr_rlc_entity_um_buffer_status; - ret->common.generate_pdu = nr_rlc_entity_um_generate_pdu; - ret->common.recv_sdu = nr_rlc_entity_um_recv_sdu; - ret->common.set_time = nr_rlc_entity_um_set_time; - ret->common.discard_sdu = nr_rlc_entity_um_discard_sdu; - ret->common.reestablishment = nr_rlc_entity_um_reestablishment; - ret->common.delete = nr_rlc_entity_um_delete; + ret->common.recv_pdu = nr_rlc_entity_um_recv_pdu; + ret->common.buffer_status = nr_rlc_entity_um_buffer_status; + ret->common.generate_pdu = nr_rlc_entity_um_generate_pdu; + ret->common.recv_sdu = nr_rlc_entity_um_recv_sdu; + ret->common.set_time = nr_rlc_entity_um_set_time; + ret->common.discard_sdu = nr_rlc_entity_um_discard_sdu; + ret->common.reestablishment = nr_rlc_entity_um_reestablishment; + ret->common.delete = nr_rlc_entity_um_delete; + ret->common.available_tx_space = nr_rlc_entity_um_available_tx_space; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; @@ -158,14 +160,15 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm( ret->tx_maxsize = tx_maxsize; - ret->common.recv_pdu = nr_rlc_entity_tm_recv_pdu; - ret->common.buffer_status = nr_rlc_entity_tm_buffer_status; - ret->common.generate_pdu = nr_rlc_entity_tm_generate_pdu; - ret->common.recv_sdu = nr_rlc_entity_tm_recv_sdu; - ret->common.set_time = nr_rlc_entity_tm_set_time; - ret->common.discard_sdu = nr_rlc_entity_tm_discard_sdu; - ret->common.reestablishment = nr_rlc_entity_tm_reestablishment; - ret->common.delete = nr_rlc_entity_tm_delete; + ret->common.recv_pdu = nr_rlc_entity_tm_recv_pdu; + ret->common.buffer_status = nr_rlc_entity_tm_buffer_status; + ret->common.generate_pdu = nr_rlc_entity_tm_generate_pdu; + ret->common.recv_sdu = nr_rlc_entity_tm_recv_sdu; + ret->common.set_time = nr_rlc_entity_tm_set_time; + ret->common.discard_sdu = nr_rlc_entity_tm_discard_sdu; + ret->common.reestablishment = nr_rlc_entity_tm_reestablishment; + ret->common.delete = nr_rlc_entity_tm_delete; + ret->common.available_tx_space = nr_rlc_entity_tm_available_tx_space; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h index b9b638fe07..5cd3bee650 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h @@ -50,6 +50,8 @@ typedef struct nr_rlc_entity_t { void (*delete)(struct nr_rlc_entity_t *entity); + int (*available_tx_space)(struct nr_rlc_entity_t *entity); + /* callbacks provided to the RLC module */ void (*deliver_sdu)(void *deliver_sdu_data, struct nr_rlc_entity_t *entity, char *buf, int size); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index af8cb5715a..ba7a4a82ee 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -1887,3 +1887,9 @@ void nr_rlc_entity_am_delete(nr_rlc_entity_t *_entity) clear_entity(entity); free(entity); } + +int nr_rlc_entity_am_available_tx_space(nr_rlc_entity_t *_entity) +{ + nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity; + return entity->tx_maxsize - entity->tx_size; +} diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h index 453fe87026..d36876ed72 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h @@ -102,5 +102,6 @@ void nr_rlc_entity_am_set_time(nr_rlc_entity_t *entity, uint64_t now); void nr_rlc_entity_am_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id); void nr_rlc_entity_am_reestablishment(nr_rlc_entity_t *_entity); void nr_rlc_entity_am_delete(nr_rlc_entity_t *entity); +int nr_rlc_entity_am_available_tx_space(nr_rlc_entity_t *entity); #endif /* _NR_RLC_ENTITY_AM_H_ */ diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c index 75408276d1..f85edbba0f 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c @@ -174,3 +174,9 @@ void nr_rlc_entity_tm_delete(nr_rlc_entity_t *_entity) clear_entity(entity); free(entity); } + +int nr_rlc_entity_tm_available_tx_space(nr_rlc_entity_t *_entity) +{ + nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity; + return entity->tx_maxsize - entity->tx_size; +} diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.h index 7c8c7e40a0..7918703799 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.h @@ -51,5 +51,6 @@ void nr_rlc_entity_tm_set_time(nr_rlc_entity_t *entity, uint64_t now); void nr_rlc_entity_tm_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id); void nr_rlc_entity_tm_reestablishment(nr_rlc_entity_t *_entity); void nr_rlc_entity_tm_delete(nr_rlc_entity_t *entity); +int nr_rlc_entity_tm_available_tx_space(nr_rlc_entity_t *entity); #endif /* _NR_RLC_ENTITY_TM_H_ */ diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c index b34a7dc894..5f2fd592a0 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c @@ -695,3 +695,9 @@ void nr_rlc_entity_um_delete(nr_rlc_entity_t *_entity) clear_entity(entity); free(entity); } + +int nr_rlc_entity_um_available_tx_space(nr_rlc_entity_t *_entity) +{ + nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity; + return entity->tx_maxsize - entity->tx_size; +} diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.h index 21063a1ea1..c40e72ada1 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.h @@ -75,5 +75,6 @@ void nr_rlc_entity_um_set_time(nr_rlc_entity_t *entity, uint64_t now); void nr_rlc_entity_um_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id); void nr_rlc_entity_um_reestablishment(nr_rlc_entity_t *_entity); void nr_rlc_entity_um_delete(nr_rlc_entity_t *entity); +int nr_rlc_entity_um_available_tx_space(nr_rlc_entity_t *entity); #endif /* _NR_RLC_ENTITY_UM_H_ */ diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index e033aa33b7..dea72d6e42 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -101,6 +101,7 @@ void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config switch (rlc_config_pr){ case NR_RLC_Config_PR_um_Bi_Directional: // RLC UM Bi-directional Bearer configuration + LOG_I(RLC, "RLC UM Bi-directional Bearer configuration selected \n"); rlc_Config->choice.um_Bi_Directional = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional)); rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength)); *rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = NR_SN_FieldLengthUM_size12; @@ -397,6 +398,35 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, return RLC_OP_STATUS_OK; } +int nr_rlc_get_available_tx_space( + const rnti_t rntiP, + const logical_chan_id_t channel_idP) +{ + nr_rlc_ue_t *ue; + nr_rlc_entity_t *rb; + int ret; + + nr_rlc_manager_lock(nr_rlc_ue_manager); + ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rntiP); + + switch (channel_idP) { + case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; + default: rb = NULL; break; + } + + if (rb != NULL) { + ret = rb->available_tx_space(rb); + } else { + LOG_E(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rntiP %x\n", __FUNCTION__, channel_idP, rntiP); + ret = -1; + } + + nr_rlc_manager_unlock(nr_rlc_ue_manager); + + return ret; +} + int rlc_module_init(int enb_flag) { static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; @@ -850,11 +880,11 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ exit(1); } - if (channel_id != drb_id + 3) { + /*if (channel_id != drb_id + 3) { LOG_E(RLC, "%s:%d:%s: todo, remove this limitation\n", __FILE__, __LINE__, __FUNCTION__); exit(1); - } + }*/ logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index 6b3c228163..92fbba9bec 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -46,4 +46,8 @@ void nr_rlc_bearer_init(NR_RLC_BearerConfig_t *RLC_BearerConfig, NR_RLC_BearerCo void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr); -void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig); \ No newline at end of file +void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig); + +int nr_rlc_get_available_tx_space( + const rnti_t rntiP, + const logical_chan_id_t channel_idP); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d7ff9492a5..11718d49b2 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3497,7 +3497,7 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co gtpv1u_DU_buffer_report_req_t *req=>PV1U_DU_BUFFER_REPORT_REQ(msg); req->pdusession_id = drb_id; req->rnti = rnti; - req->buffer_availability = 1000000; //Hardcoding to be removed and read the actual RLC buffer availability instead + req->buffer_availability = 10000000; //Hardcoding to be removed and read the actual RLC buffer availability instead extern instance_t DUuniqInstance; itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg); diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 20db486561..822825c75a 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -17,6 +17,7 @@ extern "C" { #include #include #include +#include #include "openair2/SDAP/nr_sdap/nr_sdap_gnb.h" //#include @@ -999,6 +1000,8 @@ static int Gtpv1uHandleGpdu(int h, LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); if(NR_PDCP_PDU_SN > 0 && NR_PDCP_PDU_SN %5 ==0){ LOG_D (GTPU, "Create and send DL DATA Delivery status for the previously received PDU, NR_PDCP_PDU_SN: %u \n", NR_PDCP_PDU_SN); + int rlc_tx_buffer_space = nr_rlc_get_available_tx_space(ctxt.rnti, rb_id); + LOG_D(GTPU, "Available buffer size in RLC for Tx: %d \n", rlc_tx_buffer_space); /*Total size of DDD_status PDU = 1 octet to report extension header length * size of mandatory part + 3 octets for highest transmitted/delivered PDCP SN * 1 octet for padding + 1 octet for next extension header type, @@ -1010,7 +1013,7 @@ static int Gtpv1uHandleGpdu(int h, DlDataDeliveryStatus.deliveredPdcpSn = 0; DlDataDeliveryStatus.transmittedPdcpSn= 1; DlDataDeliveryStatus.pduType = 1; - DlDataDeliveryStatus.drbBufferSize = htonl(1000000); //hardcoded for now but normally we should extract it from RLC + DlDataDeliveryStatus.drbBufferSize = htonl(rlc_tx_buffer_space); //htonl(10000000); //hardcoded for now but normally we should extract it from RLC memcpy(extensionHeader->buffer+1, &DlDataDeliveryStatus, sizeof(DlDataDeliveryStatus_flagsT)); uint8_t offset = sizeof(DlDataDeliveryStatus_flagsT)+1; From bfc7c1b36132105858fd1404e8f67ca6611f457c Mon Sep 17 00:00:00 2001 From: matzakos Date: Mon, 11 Apr 2022 19:35:05 +0200 Subject: [PATCH 49/84] Remove bad return before unlocking mutex in pdcp UL indication --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 78c2dbc34c..bcef0d5e23 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -276,8 +276,6 @@ static void do_pdcp_data_ind( } else { LOG_E(PDCP, "%s:%d:%s: no RB found (rb_id %ld, srb_flag %d)\n", __FILE__, __LINE__, __FUNCTION__, rb_id, srb_flagP); - return; - } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); From 47c9ded00714158a66774a7ac2079cb96cdccbe6 Mon Sep 17 00:00:00 2001 From: matzakos Date: Mon, 11 Apr 2022 19:53:36 +0200 Subject: [PATCH 50/84] Use higher data type to store the length of UE capability RAT container --- openair2/COMMON/f1ap_messages_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index 4a0d3eb411..92208c2b77 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -345,11 +345,11 @@ typedef struct f1ap_rb_failed_to_be_setup_s { typedef struct cu_to_du_rrc_information_s { uint8_t * cG_ConfigInfo; - uint8_t cG_ConfigInfo_length; + uint32_t cG_ConfigInfo_length; uint8_t * uE_CapabilityRAT_ContainerList; - uint8_t uE_CapabilityRAT_ContainerList_length; + uint32_t uE_CapabilityRAT_ContainerList_length; uint8_t * measConfig; - uint8_t measConfig_length; + uint32_t measConfig_length; }cu_to_du_rrc_information_t; typedef struct du_to_du_rrc_information_s { From cfda6c7b1dc73319821e60002df25d10357a254c Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 13 Apr 2022 10:58:28 +0200 Subject: [PATCH 51/84] renaming SR config function --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- openair2/RRC/NR/nr_rrc_config.c | 6 +++--- openair2/RRC/NR/nr_rrc_config.h | 6 +++--- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7e0271e609..2819394635 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1185,7 +1185,7 @@ void fill_initial_SpCellConfig(int uid, srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - schedulingrequest_config(scc, cellGroupConfig->mac_CellGroupConfig, pucch_Config); + scheduling_request_config(scc, cellGroupConfig->mac_CellGroupConfig, pucch_Config); set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 388c09c7cb..848d09b8ef 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -473,9 +473,9 @@ void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequ schedulingRequestResourceConfig->periodicityAndOffset->choice.sl640 = sr_slot; } -void schedulingrequest_config(NR_ServingCellConfigCommon_t *scc, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, - NR_PUCCH_Config_t *pucch_Config) { +void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + NR_PUCCH_Config_t *pucch_Config) { mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index f744338921..d40c4dd209 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -117,9 +117,9 @@ void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); -void schedulingrequest_config(NR_ServingCellConfigCommon_t *scc, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, - NR_PUCCH_Config_t *pucch_Config); +void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + NR_PUCCH_Config_t *pucch_Config); void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CSI_MeasConfig_t *csi_MeasConfig, int uid, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 22d3a4552c..335e7d3bda 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -861,7 +861,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); // <= 2 bits config_pucch_resset1(pucch_Config, uecap); // > 2 bits - schedulingrequest_config(servingcellconfigcommon, secondaryCellGroup->mac_CellGroupConfig, pucch_Config); + scheduling_request_config(servingcellconfigcommon, secondaryCellGroup->mac_CellGroupConfig, pucch_Config); pucch_Config->schedulingRequestResourceToReleaseList=NULL; pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; From 0c05e283e2cda03ef4cb3ff38c278b33770efe7e Mon Sep 17 00:00:00 2001 From: matzakos Date: Wed, 13 Apr 2022 13:19:04 +0200 Subject: [PATCH 52/84] Remove warnings and unused code --- openair2/F1AP/f1ap_cu_ue_context_management.c | 2 +- openair2/F1AP/f1ap_du_ue_context_management.c | 13 +++++-------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 1 + openair2/RRC/NR/rrc_gNB.c | 12 ------------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 08d0ff042e..859a9f5e0d 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -1156,7 +1156,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context ie81->id = F1AP_ProtocolIE_ID_id_RRCContainer; ie81->criticality = F1AP_Criticality_ignore; ie81->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie81->value.choice.RRCContainer, f1ap_ue_context_modification_req->rrc_container, + OCTET_STRING_fromBuf(&ie81->value.choice.RRCContainer, (const char*)f1ap_ue_context_modification_req->rrc_container, f1ap_ue_context_modification_req->rrc_container_length); } diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index ce99a31dd3..7767606804 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -233,7 +233,6 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); f1ap_ue_context_setup_req->rrc_container_length = ieRRC->value.choice.RRCContainer.size; // AssertFatal(0, "check configuration, send to appropriate handler\n"); - protocol_ctxt_t ctxt; } else { LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n"); } @@ -294,15 +293,14 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup /* OPTIONAL */ /* measGapConfig */ if (resp->du_to_cu_rrc_information->measGapConfig!=NULL) { - OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.measGapConfig, resp->du_to_cu_rrc_information->measGapConfig, + OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.measGapConfig, (const char *)resp->du_to_cu_rrc_information->measGapConfig, resp->du_to_cu_rrc_information->measGapConfig_length); } /* OPTIONAL */ /* requestedP_MaxFR1 */ if (resp->du_to_cu_rrc_information->requestedP_MaxFR1!=NULL) { - asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); - OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1, + OCTET_STRING_fromBuf(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, (const char *)resp->du_to_cu_rrc_information->requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1_length); } } @@ -1290,14 +1288,14 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex /* OPTIONAL */ /* measGapConfig */ if (resp->du_to_cu_rrc_information->measGapConfig!=NULL) { - OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.measGapConfig, resp->du_to_cu_rrc_information->measGapConfig, + OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.measGapConfig, (const char *)resp->du_to_cu_rrc_information->measGapConfig, resp->du_to_cu_rrc_information->measGapConfig_length); } /* OPTIONAL */ /* requestedP_MaxFR1 */ if (resp->du_to_cu_rrc_information->requestedP_MaxFR1!=NULL) { - OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1, + OCTET_STRING_fromBuf(ie4->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, (const char *)resp->du_to_cu_rrc_information->requestedP_MaxFR1, resp->du_to_cu_rrc_information->requestedP_MaxFR1_length); } } @@ -1358,9 +1356,8 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, f1ap_ue_contex F1AP_DRBs_Modified_Item_t *drbs_modified_item= &drbs_modified_item_ies->value.choice.DRBs_Modified_Item; /* dRBID */ drbs_modified_item->dRBID = resp->drbs_to_be_modified[i].drb_id; + /* ULTunnels_Modified_List */ - int maxnoofULTunnels = 1; // 2; - for (int j=0; jdrbs_to_be_modified[i].up_dl_tnl_length; j++) { /* DLTunnels_Modified_Item */ asn1cSequenceAdd(drbs_modified_item->dLUPTNLInformation_ToBeSetup_List.list, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 9105c9e93c..9258a2a826 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -36,6 +36,7 @@ #include #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" +extern void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 97cc60d31c..992c33cb05 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1486,18 +1486,6 @@ rrc_gNB_process_RRCReconfigurationComplete( free(DRB_Release_configList2); ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL; } - //Temporarily trigger artificially UE context release for the CU case just to be able to test it with OAI UE. To be removed later - if(0){ - if(NODE_IS_CU(RC.nrrrc[ctxt_pP->instance]->node_type)){ - MessageDef *message_p; - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); - f1ap_ue_context_release_cmd_t *rel_cmd=&F1AP_UE_CONTEXT_RELEASE_CMD (message_p); - rel_cmd->rnti = ctxt_pP->rnti; - rel_cmd->cause = F1AP_CAUSE_RADIO_NETWORK; - rel_cmd->cause_value = 10; // 10 = F1AP_CauseRadioNetwork_normal_release - itti_send_msg_to_task(TASK_CU_F1, ctxt_pP->module_id, message_p); - } - } } //----------------------------------------------------------------------------- From b216c58526c4afcea7e27cd4ae34b115efebd77b Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 15 Apr 2022 10:34:53 +0200 Subject: [PATCH 53/84] Remove xml prints of F1AP messages --- openair2/F1AP/f1ap_decoder.c | 2 +- openair2/F1AP/f1ap_encoder.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index beecf70401..60b3f94310 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -33,7 +33,7 @@ #include "f1ap_common.h" #include "f1ap_decoder.h" -int asn1_decoder_xer_print = 1; +int asn1_decoder_xer_print = 0; static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) { //MessageDef *message_p; diff --git a/openair2/F1AP/f1ap_encoder.c b/openair2/F1AP/f1ap_encoder.c index e623e66536..b249f23cfe 100644 --- a/openair2/F1AP/f1ap_encoder.c +++ b/openair2/F1AP/f1ap_encoder.c @@ -33,7 +33,7 @@ #include "f1ap_common.h" #include "f1ap_encoder.h" -int asn1_encoder_xer_print = 1; +int asn1_encoder_xer_print = 0; int f1ap_encode_pdu(F1AP_F1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *length) { ssize_t encoded; From 3feb0f472f263199e197fd7f4f9e99e61c793a1b Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 15 Apr 2022 10:35:39 +0200 Subject: [PATCH 54/84] Add more proper parsing of NR-RAN gtp-u extension header --- openair3/ocp-gtpu/gtp_itf.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 822825c75a..472ed0c44d 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -947,10 +947,20 @@ static int Gtpv1uHandleGpdu(int h, if(msgBuf[offset-1] == 0x84){ //Extension header corresponding to NR-RAN container type uint8_t PDU_type = (msgBuf[offset+1]>>4) & 0x0f; if (PDU_type == 0){ //DL USER Data Format - if((msgBuf[offset+2]>>2)& 0x3){ //"Report delivered" and "User data existence flags" enabled (TS 38.425, 5.4) + int additional_offset = 6; //Additional offset capturing the first non-mandatory octet (TS 38.425, Figure 5.5.2.1-1) + if(msgBuf[offset+1]>>2 & 0x1){ //DL Discard Blocks flag is present + LOG_I(GTPU, "DL User Data: DL Discard Blocks handling not enabled\n"); + additional_offset = additional_offset + 9; //For the moment ignore + } + if(msgBuf[offset+1]>>1 & 0x1){ //DL Flush flag is present + LOG_I(GTPU, "DL User Data: DL Flush handling not enabled\n"); + additional_offset = additional_offset + 3; //For the moment ignore + } + if((msgBuf[offset+2]>>3)& 0x1){ //"Report delivered" enabled (TS 38.425, 5.4) /*Store the NR PDCP PDU SN for which a delivery status report shall be generated once the *PDU gets forwarded to the lower layers*/ - NR_PDCP_PDU_SN = msgBuf[offset+3] << 16 | msgBuf[offset+4] << 8 | msgBuf[offset+5]; + //NR_PDCP_PDU_SN = msgBuf[offset+6] << 16 | msgBuf[offset+7] << 8 | msgBuf[offset+8]; + NR_PDCP_PDU_SN = msgBuf[offset+additional_offset] << 16 | msgBuf[offset+additional_offset+1] << 8 | msgBuf[offset+additional_offset+2]; LOG_D(GTPU, " NR_PDCP_PDU_SN: %u \n", NR_PDCP_PDU_SN); } } From 9b2a163ebb0c9766337d05a924c85c45bf46962b Mon Sep 17 00:00:00 2001 From: matzakos Date: Fri, 15 Apr 2022 10:36:31 +0200 Subject: [PATCH 55/84] Add true reporting of RLC buffer availability in first DDD report from DU to CU --- openair2/RRC/NR/rrc_gNB.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 11718d49b2..1c7b2a1ec9 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -99,6 +99,7 @@ #include #include #include +#include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "BIT_STRING.h" #include "assertions.h" @@ -3491,13 +3492,14 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co LOG_I(NR_RRC, "Send first DDD buffer status reporting towards the CU through an ITTI message to gtp-u \n"); uint8_t drb_id = ue_context_p->ue_context.DRB_configList->list.array[0]->drb_Identity; rnti_t rnti = ue_context_p->ue_context.rnti; + int rlc_tx_buffer_space = nr_rlc_get_available_tx_space(rnti, drb_id); LOG_I(NR_RRC, "Reported in DDD drb_id:%d, rnti:%d\n", drb_id, rnti); MessageDef *msg = itti_alloc_new_message_sized(TASK_RRC_GNB, 0, GTPV1U_DU_BUFFER_REPORT_REQ, sizeof(gtpv1u_gnb_tunnel_data_req_t)); gtpv1u_DU_buffer_report_req_t *req=>PV1U_DU_BUFFER_REPORT_REQ(msg); req->pdusession_id = drb_id; req->rnti = rnti; - req->buffer_availability = 10000000; //Hardcoding to be removed and read the actual RLC buffer availability instead + req->buffer_availability = rlc_tx_buffer_space; //10000000; //Hardcoding to be removed and read the actual RLC buffer availability instead extern instance_t DUuniqInstance; itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg); From a037987b474e25f2f0011eabe149228e689ddd38 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 9 May 2022 18:28:56 +0200 Subject: [PATCH 56/84] remove ssb subcarrier offset from config file --- ci-scripts/conf_files/benetel-5g.conf | 2 -- ...sci_gnb.band78.sa.fr1.106PRB.usrpn310.conf | 1 - .../episci_rcc.band78.tm1.106PRB.nfapi.conf | 1 - ...oxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf | 1 - .../proxy_rcc.band78.tm1.106PRB.nfapi.conf | 1 - ci-scripts/conf_files/gNB_SA_CU.conf | 1 - ci-scripts/conf_files/gNB_SA_DU.conf | 1 - .../gNB_SA_n78_106PRB.2x2_usrpn310.conf | 1 - .../gNB_SA_n78_133PRB.2x2_usrpn310.conf | 1 - .../gnb.band261.tm1.32PRB.usrpn300.conf | 1 - .../gnb.band66.tm1.106PRB.usrpn300.conf | 1 - .../gnb.band78.nsa_2x2.106PRB.usrpn310.conf | 1 - ...and78.sa.fr1.106PRB.2x2.usrpn310.asue.conf | 1 - ...gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf | 1 - ...nd78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf | 1 - .../gnb.band78.sa.fr1.106PRB.usrpn310.conf | 1 - ...gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf | 1 - .../gnb.band78.tm1.106PRB.usrpn300.conf | 1 - .../gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 1 - .../gnb.band78.tm1.fr1.106PRB.usrpn310.conf | 1 - .../gnb.sa.band66.fr1.106PRB.usrpn300.conf | 1 - .../gnb.sa.band78.fr1.24PRB.usrpb210.conf | 3 -- doc/testing_gnb_w_cots_ue_resources/gnb.conf | 2 -- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 17 ++-------- openair1/SIMULATION/NR_PHY/dlsim.c | 8 ++--- openair1/SIMULATION/NR_PHY/pbchsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 4 +-- openair2/COMMON/rrc_messages_types.h | 1 - openair2/GNB_APP/gnb_config.c | 3 -- openair2/GNB_APP/gnb_paramdef.h | 29 ++++++++--------- openair2/LAYER2/NR_MAC_UE/config_ue.c | 4 ++- openair2/LAYER2/NR_MAC_gNB/config.c | 31 ++++++++----------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 12 ------- openair2/RRC/NR/MESSAGES/asn1_msg.c | 21 ++++++++----- openair2/RRC/NR/rrc_gNB.c | 4 --- openair2/RRC/NR/rrc_gNB_nsa.c | 2 -- .../GENERIC-LTE-EPC/CONF/benetel-5g.conf | 1 - .../CONF/gnb.band257.tm1.32PRB.usrpn300.conf | 1 - .../CONF/gnb.band257.tm1.32PRB.usrpx300.conf | 1 - .../CONF/gnb.band257.tm1.66PRB.usrpn300.conf | 2 -- .../CONF/gnb.band261.tm1.32PRB.usrpn300.conf | 1 - .../CONF/gnb.band66.tm1.106PRB.usrpn300.conf | 1 - .../CONF/gnb.band66.tm1.106PRB.usrpx300.conf | 2 -- .../gnb.band78.106PRB.30kHz,usrpb2x0.conf | 1 - .../CONF/gnb.band78.106PRB.slave.conf | 1 - .../CONF/gnb.band78.slave.conf | 2 -- .../gnb.band78.tm1.106PRB.PTRS.usrpx300.conf | 2 -- .../CONF/gnb.band78.tm1.106PRB.usrpb210.conf | 2 -- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 -- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 2 -- .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf | 2 -- .../CONF/gnb.band78.tm1.217PRB.usrpx300.conf | 1 - .../CONF/gnb.band78.tm1.24PRB.usrpb210.conf | 1 - .../CONF/gnb.band78.tm1.24PRB.usrpn300.conf | 1 - .../CONF/gnb.band78.tm1.24PRB.usrpx300.conf | 1 - .../CONF/gnb.band78.tm1.273PRB.usrpn300.conf | 1 - .../CONF/rcc.band78.tm1.106PRB.nfapi.conf | 1 - .../GENERIC-LTE-EPC/CONF/testing_gnb.conf | 2 -- .../CONF/testing_gnb_24PRB.conf | 2 -- .../CONF/testing_gnb_n310.conf | 2 -- .../CONF/testing_gnb_nsa_n310.conf | 1 - .../PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf | 1 - .../PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf | 1 - ...b.band78.tm1.106PRB.usrpn300.gtp-itti.conf | 1 - .../gnb.sa.band41.fr1.106PRB.usrpb210.conf | 2 -- .../gnb.sa.band66.fr1.106PRB.usrpn300.conf | 3 -- ...gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf | 1 - .../gnb.sa.band78.fr1.106PRB.usrpb210.conf | 1 - ...b.sa.band78.fr1.106PRB.usrpb210.sabox.conf | 1 - ...gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf | 1 - .../gnb.sa.band78.fr1.24PRB.usrpb210.conf | 3 -- 71 files changed, 52 insertions(+), 164 deletions(-) diff --git a/ci-scripts/conf_files/benetel-5g.conf b/ci-scripts/conf_files/benetel-5g.conf index 8f3b03fddc..3b872e56e9 100644 --- a/ci-scripts/conf_files/benetel-5g.conf +++ b/ci-scripts/conf_files/benetel-5g.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf index 51ffb1d5cd..a648db0efe 100644 --- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -32,7 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( { diff --git a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf index eac0b74633..0db6ac9036 100644 --- a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf index f80ce3751a..84cb18d435 100644 --- a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -32,7 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf index f61039ff17..270ad75845 100644 --- a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gNB_SA_CU.conf b/ci-scripts/conf_files/gNB_SA_CU.conf index 9d64ae1976..f6d3e8575a 100644 --- a/ci-scripts/conf_files/gNB_SA_CU.conf +++ b/ci-scripts/conf_files/gNB_SA_CU.conf @@ -44,7 +44,6 @@ gNBs = local_s_portd = 2152; remote_s_portc = 500; remote_s_portd = 2152; - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/ci-scripts/conf_files/gNB_SA_DU.conf b/ci-scripts/conf_files/gNB_SA_DU.conf index f95bdf91ae..4309c13dd3 100644 --- a/ci-scripts/conf_files/gNB_SA_DU.conf +++ b/ci-scripts/conf_files/gNB_SA_DU.conf @@ -36,7 +36,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf index d6edc09286..06d9aed610 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf @@ -37,7 +37,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; diff --git a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf index 7f4b11c35d..8ff9d73e9a 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf @@ -38,7 +38,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index dcb3dd89b7..24ec8f17f8 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf index 1019ec75ad..b3c7d7d1da 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf index fa7c190538..0e68844050 100644 --- a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf @@ -19,7 +19,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf index 5e6b3fb217..92c3a7a2e9 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf @@ -41,7 +41,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" do_SRS = 1; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index 8489008300..f2157e36d9 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -37,7 +37,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf index 18ca7b5d1e..5bd8b26e05 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf @@ -37,7 +37,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" do_SRS = 1; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf index 9e1f499f03..e1264bd069 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -37,7 +37,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; #pusch_TargetSNRx10 = 200; #pucch_TargetSNRx10 = 200; ul_prbblacklist = "51,52,53,54" diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index ce63578dd3..d22afe1c2f 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -37,7 +37,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; #pusch_TargetSNRx10 = 200; diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 0c75080398..c8349a43e3 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index f3515d3882..cd3ab6278e 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -19,7 +19,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; servingCellConfigCommon = ( { diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf index 8f480d3757..371753eccc 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf @@ -20,7 +20,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf index b78ca916f3..197e1d211c 100644 --- a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -32,7 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf index bd3076a014..ad1471339a 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -32,9 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; sib1_tda = 15; min_rxtxtime = 6; diff --git a/doc/testing_gnb_w_cots_ue_resources/gnb.conf b/doc/testing_gnb_w_cots_ue_resources/gnb.conf index c96d207445..206e1b4f02 100755 --- a/doc/testing_gnb_w_cots_ue_resources/gnb.conf +++ b/doc/testing_gnb_w_cots_ue_resources/gnb.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index dca97bddf0..de8f4810ab 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -50,19 +50,6 @@ uint8_t SSB_Table[38]={0,2,4,6,8,10,12,14,254,254,16,18,20,22,24,26,28,30,254,25 extern uint8_t nfapi_mode; -void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp) { - - uint8_t sco = 0; - if (((fp->freq_range == nr_FR1) && (cfg->ssb_table.ssb_subcarrier_offset.value<24)) || - ((fp->freq_range == nr_FR2) && (cfg->ssb_table.ssb_subcarrier_offset.value<12)) ) { - if (fp->freq_range == nr_FR1) - sco = cfg->ssb_table.ssb_subcarrier_offset.value>>cfg->ssb_config.scs_common.value; - } - - fp->ssb_start_subcarrier = (12 * cfg->ssb_table.ssb_offset_point_a.value + sco); - LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,sco); -} - void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_dl_tti_ssb_pdu ssb_pdu) { NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; @@ -84,7 +71,9 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp,ssb_index); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % fp->symbols_per_slot; // start symbol wrt slot - nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier + // setting the first subcarrier + fp->ssb_start_subcarrier = (12 * cfg->ssb_table.ssb_offset_point_a.value + ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset); + LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset); LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); nr_generate_pss(&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index eff65fa606..7346382735 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -210,11 +210,9 @@ int nr_derive_key(int alg_type, uint8_t alg_id, } void config_common(int Mod_idP, - int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, - NR_ServingCellConfigCommon_t *scc - ); + NR_ServingCellConfigCommon_t *scc); int generate_dlsch_header(unsigned char *mac_header, unsigned char num_sdus, @@ -831,9 +829,9 @@ int main(int argc, char **argv) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 0, 0, NULL); + rrc_mac_config_req_gNB(0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + rrc_mac_config_req_gNB(0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); // reset preprocessor to the one of DLSIM after it has been set during // rrc_mac_config_req_gNB gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 62f6b21528..7099eda90c 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -457,7 +457,7 @@ int main(int argc, char **argv) nr_phy_config_request_sim_pbchsim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,1); - nr_set_ssb_first_subcarrier(&gNB->gNB_config,frame_parms); + fp->ssb_start_subcarrier = 12 * gNB->gNB_config->ssb_table.ssb_offset_point_a.value uint8_t n_hf = 0; int cyclic_prefix_type = NFAPI_CP_NORMAL; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index e70d08bdb3..e50671c280 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -756,9 +756,9 @@ int main(int argc, char **argv) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 0, 0, NULL); + rrc_mac_config_req_gNB(0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + rrc_mac_config_req_gNB(0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 5b214cf95a..b0f0b72e0a 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -417,7 +417,6 @@ typedef struct NRRrcConfigurationReq_s { uint8_t num_plmn; NR_ServingCellConfigCommon_t *scc; NR_ServingCellConfig_t *scd; - int ssb_SubcarrierOffset; int sib1_tda; rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts; int pusch_AntennaPorts; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 62dc72a857..3ad460ae44 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1169,8 +1169,6 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { (NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l] == 3),"BAD MNC DIGIT LENGTH %d", NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l]); } - LOG_I(GNB_APP,"SSB SCO %d\n",*GNBParamList.paramarray[i][GNB_SSB_SUBCARRIEROFFSET_IDX].iptr); - NRRRC_CONFIGURATION_REQ (msg_p).ssb_SubcarrierOffset = *GNBParamList.paramarray[i][GNB_SSB_SUBCARRIEROFFSET_IDX].iptr; LOG_I(RRC,"pdsch_AntennaPorts N1 %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts.N1 = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr; LOG_I(RRC,"pdsch_AntennaPorts N2 %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr); @@ -2055,7 +2053,6 @@ void configure_gnb_du_mac(int inst) { // LOG_I(GNB_APP,"Configuring MAC/L1 %d, carrier->sib2 %p\n", inst, &carrier->sib2->radioResourceConfigCommon); LOG_I(GNB_APP,"Configuring gNB DU MAC/L1 %d \n", inst); rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index 52dcbd3152..2ecc8f2e99 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -113,7 +113,6 @@ typedef enum { #define GNB_CONFIG_STRING_REMOTE_S_PORTC "remote_s_portc" #define GNB_CONFIG_STRING_LOCAL_S_PORTD "local_s_portd" #define GNB_CONFIG_STRING_REMOTE_S_PORTD "remote_s_portd" -#define GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET "ssb_SubcarrierOffset" #define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1 "pdsch_AntennaPorts_N1" #define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2 "pdsch_AntennaPorts_N2" #define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP "pdsch_AntennaPorts_XP" @@ -149,7 +148,6 @@ typedef enum { {GNB_CONFIG_STRING_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defuintval:50000, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \ -{GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET, NULL, 0, iptr:NULL, defintval:31, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1, "horiz. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2, "vert. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP, "XP log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ @@ -179,20 +177,19 @@ typedef enum { #define GNB_REMOTE_S_PORTC_IDX 11 #define GNB_LOCAL_S_PORTD_IDX 12 #define GNB_REMOTE_S_PORTD_IDX 13 -#define GNB_SSB_SUBCARRIEROFFSET_IDX 14 -#define GNB_PDSCH_ANTENNAPORTS_N1_IDX 15 -#define GNB_PDSCH_ANTENNAPORTS_N2_IDX 16 -#define GNB_PDSCH_ANTENNAPORTS_XP_IDX 17 -#define GNB_PUSCH_ANTENNAPORTS_IDX 18 -#define GNB_SIB1_TDA_IDX 19 -#define GNB_DO_CSIRS_IDX 20 -#define GNB_DO_SRS_IDX 21 -#define GNB_NRCELLID_IDX 22 -#define GNB_MINRXTXTIME_IDX 23 -#define GNB_ULPRBBLACKLIST_IDX 24 -#define GNB_UMONDEFAULTDRB_IDX 25 -#define GNB_FORCE256QAMOFF_IDX 26 -#define GNB_ENABLE_SDAP_IDX 27 +#define GNB_PDSCH_ANTENNAPORTS_N1_IDX 14 +#define GNB_PDSCH_ANTENNAPORTS_N2_IDX 15 +#define GNB_PDSCH_ANTENNAPORTS_XP_IDX 16 +#define GNB_PUSCH_ANTENNAPORTS_IDX 17 +#define GNB_SIB1_TDA_IDX 18 +#define GNB_DO_CSIRS_IDX 19 +#define GNB_DO_SRS_IDX 20 +#define GNB_NRCELLID_IDX 21 +#define GNB_MINRXTXTIME_IDX 22 +#define GNB_ULPRBBLACKLIST_IDX 23 +#define GNB_UMONDEFAULTDRB_IDX 24 +#define GNB_FORCE256QAMOFF_IDX 25 +#define GNB_ENABLE_SDAP_IDX 26 #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define GNBPARAMS_CHECK { \ diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index bd693e4d88..34369d0861 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -343,7 +343,9 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); cfg->ssb_table.ssb_offset_point_a = absolute_diff/(12*scs_scaling) - 10; cfg->ssb_table.ssb_period = *scc->ssb_periodicityServingCell; - cfg->ssb_table.ssb_subcarrier_offset = mac->ssb_subcarrier_offset; + + // NSA -> take ssb offset from SSC + cfg->ssb_table.ssb_subcarrier_offset = absolute_diff%(12*scs_scaling); switch (scc->ssb_PositionsInBurst->present) { case 1 : diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 9dff368ccc..468d6faaee 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -160,7 +160,7 @@ void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sche } -void config_common(int Mod_idP, int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts_t dl_antenna_ports_struct, int pusch_AntennaPorts, NR_ServingCellConfigCommon_t *scc) { +void config_common(int Mod_idP, rrc_pdsch_AntennaPorts_t dl_antenna_ports_struct, int pusch_AntennaPorts, NR_ServingCellConfigCommon_t *scc) { nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[Mod_idP]->config[0]; RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon = scc; @@ -342,26 +342,24 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666) scs_scaling = scs_scaling>>2; uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); - uint16_t sco = absolute_diff%(12*scs_scaling); - // values of subcarrier offset larger than the limit only indicates CORESET for Type0-PDCCH CSS set is not present - int ssb_SubcarrierOffset_limit = 0; - int offset_scaling = 0; //15kHz - if(frequency_range == FR1) { - ssb_SubcarrierOffset_limit = 24; - if (ssb_SubcarrierOffsetssb_config.scs_common.value; - } else - ssb_SubcarrierOffset_limit = 12; - if (ssb_SubcarrierOffsetssb_SubcarrierOffset = absolute_diff%(12*scs_scaling); + int sco; + if(get_softmodem_params()->sa) { + sco = RC.nrmac[Mod_idP]->ssb_SubcarrierOffset; + if(frequency_range == FR1) + sco = sco<ssb_config.scs_common.value; + } + else + sco = 31; // no SIB1 + cfg->ssb_table.ssb_offset_point_a.value = absolute_diff/(12*scs_scaling) - 10; //absoluteFrequencySSB is the central frequency of SSB which is made by 20RBs in total cfg->ssb_table.ssb_offset_point_a.tl.tag = NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG; cfg->num_tlv++; cfg->ssb_table.ssb_period.value = *scc->ssb_periodicityServingCell; cfg->ssb_table.ssb_period.tl.tag = NFAPI_NR_CONFIG_SSB_PERIOD_TAG; cfg->num_tlv++; - cfg->ssb_table.ssb_subcarrier_offset.value = ssb_SubcarrierOffset<ssb_table.ssb_subcarrier_offset.value = sco; cfg->ssb_table.ssb_subcarrier_offset.tl.tag = NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG; cfg->num_tlv++; @@ -473,7 +471,6 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_S } int rrc_mac_config_req_gNB(module_id_t Mod_idP, - int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, @@ -509,7 +506,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, LOG_I(NR_MAC,"Configuring common parameters from NR ServingCellConfig\n"); config_common(Mod_idP, - ssb_SubcarrierOffset, pdsch_AntennaPorts, pusch_AntennaPorts, scc); @@ -523,7 +519,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, printf("Waiting for PHY_config_req\n"); } } - RC.nrmac[Mod_idP]->ssb_SubcarrierOffset = ssb_SubcarrierOffset; RC.nrmac[Mod_idP]->minRXTXTIMEpdsch = minRXTXTIMEpdsch; NR_PHY_Config_t phycfg; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 9cb4dd88b2..5b5e6e1f7e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -41,7 +41,6 @@ void mac_top_init_gNB(void); void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); void config_common(int Mod_idP, - int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, NR_ServingCellConfigCommon_t *scc); @@ -52,7 +51,6 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, uint32_t rrc_reconfiguration_delay); int rrc_mac_config_req_gNB(module_id_t Mod_idP, - int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, @@ -433,16 +431,6 @@ int get_ulscs(nfapi_nr_config_request_t *cfg); int get_symbolsperslot(nfapi_nr_config_request_t *cfg); -void config_nr_mib(int Mod_idP, - int CC_idP, - int p_gNBP, - int subCarrierSpacingCommon, - uint32_t ssb_SubcarrierOffset, - int dmrs_TypeA_Position, - uint32_t pdcch_ConfigSIB1, - int cellBarred, - int intraFreqReselection); - int nr_write_ce_dlsch_pdu(module_id_t module_idP, const NR_UE_sched_ctrl_t *ue_sched_ctl, unsigned char *mac_pdu, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 8e8959c597..5ef4e1c001 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -41,6 +41,7 @@ #include #include +#include "executables/softmodem-common.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "asn1_msg.h" #include "../nr_rrc_proto.h" @@ -197,8 +198,7 @@ int xer_nr_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { asn_enc_rval_t enc_rval; - rrc_gNB_carrier_data_t *carrier = &rrc->carrier; - const gNB_RrcConfigurationReq *configuration = &rrc->configuration; + rrc_gNB_carrier_data_t *carrier = &rrc->carrier; NR_BCCH_BCH_Message_t *mib = &carrier->mib; NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; @@ -225,11 +225,18 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n"); int band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; frequency_range_t frequency_range = band<100?FR1:FR2; - int ssb_subcarrier_offset; - if(frequency_range == FR1) - ssb_subcarrier_offset = (configuration->ssb_SubcarrierOffset<24) ? (configuration->ssb_SubcarrierOffset<<*scc->ssbSubcarrierSpacing) : configuration->ssb_SubcarrierOffset; - else - ssb_subcarrier_offset = configuration->ssb_SubcarrierOffset; + int scs_scaling = 1<<*scc->ssbSubcarrierSpacing; + if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000) + scs_scaling = scs_scaling*3; + if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666) + scs_scaling = scs_scaling>>2; + uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); + int ssb_subcarrier_offset = 31; // default value for NSA + if (get_softmodem_params()->sa) { + ssb_subcarrier_offset = absolute_diff%(12*scs_scaling); + if(frequency_range == FR1) + ssb_subcarrier_offset = ssb_subcarrier_offset<<*scc->ssbSubcarrierSpacing; + } mib->message.choice.mib->ssb_SubcarrierOffset = ssb_subcarrier_offset&15; /* diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a0706509a7..8e1ed3d6a5 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -166,7 +166,6 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration if (NODE_IS_MONOLITHIC(rrc->node_type)){ rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, @@ -275,7 +274,6 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL; rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, @@ -463,7 +461,6 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_gNB(rrc_instance_p->module_id, - rrc_instance_p->configuration.ssb_SubcarrierOffset, rrc_instance_p->configuration.pdsch_AntennaPorts, rrc_instance_p->configuration.pusch_AntennaPorts, rrc_instance_p->configuration.sib1_tda, @@ -1398,7 +1395,6 @@ rrc_gNB_process_RRCReconfigurationComplete( if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index b482637dfd..cd094a6d05 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -344,7 +344,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ // configure MAC and RLC if (NODE_IS_DU(rrc->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, @@ -357,7 +356,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ue_context_p->ue_context.secondaryCellGroup); } else { rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index d14267dcd8..c8e109d302 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -22,7 +22,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf index 52e4eec30e..a4c877a7ba 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index ab435c9686..e5478983cf 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf index a04e0e6123..efa0d3e2fa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index 426f9e782b..8a2ce9f63e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf index 216728577a..616f86a1cd 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf index 59d466656c..0818fe11d7 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index 2ae4df07d9..5c636af06c 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf index 21267870bd..812ac8dafb 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf index a0fd0bda9f..781384a789 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf @@ -20,8 +20,6 @@ gNBs = tr_s_preference = "local_mac" ////////// Physical parameters: - - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf index 5c8f90d9b5..1450c45eee 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf index 7bf3626870..562e2b16ab 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 1773e1fb79..b7dc93497f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index d0f394be16..10122b9eb2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 0438e61337..20d01c2a00 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -20,8 +20,6 @@ gNBs = tr_s_preference = "local_mac" ////////// Physical parameters: - - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf index 66c2151eb8..44f3889eec 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf index c6ea066fc4..fbafef81b4 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf index fcfe58a3c0..38d6ed3c61 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf index 2ad9757cb1..b7da7b17f4 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf index 44074f3fd9..9f78716bcc 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf index 7ce150506f..1dcef89736 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index 306e652eaa..9a3fe358a5 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf index d08c0f14a0..9e1ae24d67 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; - servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf index e3204db8fa..9ec28b93e7 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf @@ -20,8 +20,6 @@ gNBs = tr_s_preference = "local_mac" ////////// Physical parameters: - - ssb_SubcarrierOffset = 31; //0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf index 030dc10226..35778ef705 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf @@ -21,7 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 31; //0; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index 6aacd98c7f..a64a4c6022 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -44,7 +44,6 @@ gNBs = local_s_portd = 2152; remote_s_portc = 500; remote_s_portd = 2152; - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index f95bdf91ae..4309c13dd3 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -36,7 +36,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf index f91683897f..cb90889b52 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf @@ -36,7 +36,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index e645094e8b..b61708a6d8 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -28,8 +28,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - min_rxtxtime = 2; do_SRS = 1; pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf index ff64fe718a..6abf2c19cc 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -32,9 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 2881a77d48..5249785c8e 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -28,7 +28,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; do_SRS = 1; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index e3024737ee..baf5c6d0ff 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -28,7 +28,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; min_rxtxtime = 2; pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf index 8ca0c08876..6719a5534d 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf @@ -30,7 +30,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index b8d71015c1..1bd5117bdb 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -28,7 +28,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 2; ul_prbblacklist = "79,80,81,82" diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf index bd3076a014..ad1471339a 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -32,9 +32,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; sib1_tda = 15; min_rxtxtime = 6; From 3b165473741a73420920446a33b41cf38c03e592 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 10 May 2022 09:13:52 +0200 Subject: [PATCH 57/84] fix in pbchsim --- openair1/SIMULATION/NR_PHY/pbchsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 7099eda90c..4e7d2a67e1 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -457,7 +457,7 @@ int main(int argc, char **argv) nr_phy_config_request_sim_pbchsim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,1); - fp->ssb_start_subcarrier = 12 * gNB->gNB_config->ssb_table.ssb_offset_point_a.value + frame_parms->ssb_start_subcarrier = 12 * gNB->gNB_config.ssb_table.ssb_offset_point_a.value; uint8_t n_hf = 0; int cyclic_prefix_type = NFAPI_CP_NORMAL; From c7e8002d8d4a211c2d82ee3b62309457e46b95dd Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 10 May 2022 11:43:44 +0200 Subject: [PATCH 58/84] adding CI test with subcarrier offset in pbchsim --- cmake_targets/autotests/test_case_list.xml | 8 +++++--- openair1/SIMULATION/NR_PHY/pbchsim.c | 15 +++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index b55228bdc9..41e1bcd6b0 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1062,7 +1062,8 @@ (Test3: PBCH-only, 217 PRB), (Test4: PBCH and synchronization, 217 RPB), (Test5: PBCH-only, 273 PRB), - (Test6: PBCH and synchronization, 273 PRB) + (Test6: PBCH and synchronization, 273 PRB), + (Test7: PBCH and synchronization, 106PBR, SSB SC OFFSET 6) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1074,8 +1075,9 @@ -s-11 -S-8 -n10 -R217 -s-11 -S-8 -n10 -o8000 -I -R217 -s-11 -S-8 -n10 -R273 - -s-11 -S-8 -n10 -o8000 -I -R273 - nr_pbchsim.test1 nr_pbchsim.test2 nr_pbchsim.test3 nr_pbchsim.test4 nr_pbchsim.test5 nr_pbchsim.test6 + -s-11 -S-8 -n10 -o8000 -I -R273 + -s-11 -S-8 -n10 -R106 -O6 + nr_pbchsim.test1 nr_pbchsim.test2 nr_pbchsim.test3 nr_pbchsim.test4 nr_pbchsim.test5 nr_pbchsim.test6 nr_pbchsim.test7 PBCH test OK segmentation fault|assertion|exiting|fatal 3 diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 4e7d2a67e1..b4d81824e2 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -171,6 +171,7 @@ int main(int argc, char **argv) uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; uint64_t SSB_positions=0x01; + int ssb_subcarrier_offset = 0; channel_desc_t *gNB2UE; @@ -214,7 +215,7 @@ int main(int argc, char **argv) exit_fun("[NR_PBCHSIM] Error, configuration module init failed\n"); } - while ((c = getopt (argc, argv, "F:g:hIL:m:M:n:N:o:P:r:R:s:S:x:y:z:")) != -1) { + while ((c = getopt (argc, argv, "F:g:hIL:m:M:n:N:o:O:P:r:R:s:S:x:y:z:")) != -1) { switch (c) { /*case 'f': write_output_file=1; @@ -312,6 +313,10 @@ int main(int argc, char **argv) Nid_cell = atoi(optarg); break; + case 'O': + ssb_subcarrier_offset = atoi(optarg); + break; + case 'o': cfo = atof(optarg); #ifdef DEBUG_NR_PBCHSIM @@ -414,6 +419,7 @@ int main(int argc, char **argv) printf("-n Number of frames to simulate\n"); printf("-N Nid_cell\n"); printf("-o Carrier frequency offset in Hz\n"); + printf("-O SSB subcarrier offset\n"); //printf("-O oversampling factor (1,2,4,8,16)\n"); //printf("-p Use extended prefix mode\n"); printf("-P PBCH phase, allowed values 0-3\n"); @@ -457,7 +463,7 @@ int main(int argc, char **argv) nr_phy_config_request_sim_pbchsim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,1); - frame_parms->ssb_start_subcarrier = 12 * gNB->gNB_config.ssb_table.ssb_offset_point_a.value; + frame_parms->ssb_start_subcarrier = 12 * gNB->gNB_config.ssb_table.ssb_offset_point_a.value + ssb_subcarrier_offset; uint8_t n_hf = 0; int cyclic_prefix_type = NFAPI_CP_NORMAL; @@ -582,6 +588,7 @@ int main(int argc, char **argv) msgDataTx.ssb[i].ssb_pdu.ssb_pdu_rel15.bchPayload = 0x55dd33; msgDataTx.ssb[i].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = i; + msgDataTx.ssb[i].ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset = ssb_subcarrier_offset; start_symbol = nr_get_ssb_start_symbol(frame_parms,i); int slot = start_symbol/14; @@ -724,8 +731,8 @@ int main(int argc, char **argv) if (ret<0) n_errors++; } else { - UE_nr_rxtx_proc_t proc={0}; - NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + UE_nr_rxtx_proc_t proc={0}; + NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; UE->rx_offset=0; uint8_t ssb_index = 0; From 68be6f83e6dba23bed1a365696c31451c645c3ac Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 10 May 2022 13:59:36 +0200 Subject: [PATCH 59/84] randominit(): show used seed when using time() --- openair1/SIMULATION/TOOLS/rangen_double.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 82b1557a5b..0ba9e196b1 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -42,7 +42,6 @@ void randominit(unsigned seed_init) { int i; // this need to be integrated with the existing rng, like taus: navid - printf("Initializing random number generator, seed %x\n",seed_init); if (seed_init == 0) { srand((unsigned)time(NULL)); @@ -51,6 +50,7 @@ void randominit(unsigned seed_init) } else { seed = seed_init; } + printf("Initializing random number generator, seed %x\n",seed); if (seed % 2 == 0) seed += 1; /* seed and mod are relative prime */ From 6d736db22d03d187becf16ddc4cda03ea3a6a0b7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 18 May 2022 17:23:55 +0200 Subject: [PATCH 60/84] applying PUCCH harmonization to multiple BWP --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 116 +++---------------- openair2/RRC/NR/nr_rrc_config.c | 9 -- openair2/RRC/NR/nr_rrc_config.h | 1 - openair2/RRC/NR/rrc_gNB_reconfig.c | 174 +++++++--------------------- 4 files changed, 58 insertions(+), 242 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 82a0cd572f..d9e4658be2 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1265,6 +1265,8 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Common->genericParameters.cyclicPrefix = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; } + int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + ubwp->bwp_Common->rach_ConfigCommon = NULL; ubwp->bwp_Common->pusch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; ubwp->bwp_Common->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; @@ -1277,109 +1279,17 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchres0id0=calloc(1,sizeof(*pucchres0id0)); - *pucchres0id0=ubwp->bwp_Id; // To uniquely identify each pucchresource lets derive it from the BWPId - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchres0id0); - pucchresset0->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; - int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - pucchres0->pucch_ResourceId=*pucchres0id0; - pucchres0->startingPRB=(8+uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL); + config_pucch_resset1(pucch_Config, NULL); + set_pucch_power_config(pucch_Config, configuration->do_CSIRS); -/* - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; -*/ - - // PUCCH config - Scheduling request configuration - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; // 40 slot period - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). - // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. - // Check for above configuration and exit for now if it is not the case - AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, - "SCS != 30kHz\n"); - AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, - "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = *pucchres0id0; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(configuration->minRXTXTIME >=2 && configuration->minRXTXTIME <7, "check minRXTXTIME %d\n",configuration->minRXTXTIME); - *delay[i] = i+configuration->minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(configuration->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; + scheduling_request_config(scc, pucch_Config); + set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME); // PUSCH config ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); @@ -1714,7 +1624,7 @@ void fill_initial_SpCellConfig(int uid, srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - scheduling_request_config(scc, cellGroupConfig->mac_CellGroupConfig, pucch_Config); + scheduling_request_config(scc, pucch_Config); set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME); @@ -2255,6 +2165,14 @@ void fill_initial_cellGroupConfig(int uid, mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10; mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1; + mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); + mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); + schedulingrequestlist->schedulingRequestId = 0; + schedulingrequestlist->sr_ProhibitTimer = NULL; + schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; + ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + cellGroupConfig->mac_CellGroupConfig = mac_CellGroupConfig; physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index e1c62e18c1..eeb7fe9028 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -593,17 +593,8 @@ void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequ } void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config) { - mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); - schedulingrequestlist->schedulingRequestId = 0; - schedulingrequestlist->sr_ProhibitTimer = NULL; - schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; - ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); - // format with <=2 bits in pucch resource set 0 NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[0]; // assigning the 1st pucch resource in the set to scheduling request diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 06e5eaef45..575f642290 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -120,7 +120,6 @@ void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_PUCCH_Config_t *pucch_Config); void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CSI_MeasConfig_t *csi_MeasConfig, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 830383e005..79f897ef9a 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -366,128 +366,26 @@ void fill_default_nsa_uplinkBWP(NR_BWP_Uplink_t *ubwp, /// BWP dedicated configuration - if (!ubwp->bwp_Dedicated) { + if (!ubwp->bwp_Dedicated) ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); - } + + int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); + ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - *pucchresset0id0=1; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - pucchresset0->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); - - pucchresset1->pucch_ResourceSetId = 1; - NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); - *pucchresset1id0=2; - ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); - pucchresset1->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL); + config_pucch_resset1(pucch_Config, NULL); + set_pucch_power_config(pucch_Config, configuration->do_CSIRS); - int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); - - pucchres0->pucch_ResourceId=1; - pucchres0->startingPRB= (8 + uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - - pucchres2->pucch_ResourceId=2; - pucchres2->startingPRB=0; - pucchres2->intraSlotFrequencyHopping=NULL; - pucchres2->secondHopPRB=NULL; - pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; - pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); - pucchres2->format.choice.format2->nrofPRBs=8; - pucchres2->format.choice.format2->nrofSymbols=1; - pucchres2->format.choice.format2->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); - - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; - - // for scheduling requestresource - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = 1; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - *delay[i] = i + configuration->minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(configuration->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; + scheduling_request_config(servingcellconfigcommon, pucch_Config); + set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME); ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; @@ -693,31 +591,33 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList)); ASN_SEQUENCE_ADD(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig); - secondaryCellGroup->mac_CellGroupConfig=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig)); - secondaryCellGroup->mac_CellGroupConfig->drx_Config = NULL; + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = secondaryCellGroup->mac_CellGroupConfig; - secondaryCellGroup->mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->bsr_Config)); - secondaryCellGroup->mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; - secondaryCellGroup->mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf160; - secondaryCellGroup->mac_CellGroupConfig->tag_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config)); - secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; - secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList)); + mac_CellGroupConfig=calloc(1,sizeof(*mac_CellGroupConfig)); + mac_CellGroupConfig->drx_Config = NULL; + + mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*mac_CellGroupConfig->bsr_Config)); + mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; + mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf160; + mac_CellGroupConfig->tag_Config=calloc(1,sizeof(*mac_CellGroupConfig->tag_Config)); + mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; + mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); struct NR_TAG *tag=calloc(1,sizeof(*tag)); tag->tag_Id = 0; tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; - ASN_SEQUENCE_ADD(&secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - secondaryCellGroup->mac_CellGroupConfig->phr_Config = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->phr_Config)); - secondaryCellGroup->mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup)); - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf20; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf0; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB3; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->multiplePHR=false; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->dummy=false; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_Type2OtherCell = false; - secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_ModeOtherCG = NR_PHR_Config__phr_ModeOtherCG_real; - secondaryCellGroup->mac_CellGroupConfig->skipUplinkTxDynamic=false; - secondaryCellGroup->mac_CellGroupConfig->ext1 = NULL; + ASN_SEQUENCE_ADD(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); + mac_CellGroupConfig->phr_Config = calloc(1,sizeof(*mac_CellGroupConfig->phr_Config)); + mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; + mac_CellGroupConfig->phr_Config->choice.setup = calloc(1,sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); + mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf20; + mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf0; + mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB3; + mac_CellGroupConfig->phr_Config->choice.setup->multiplePHR=false; + mac_CellGroupConfig->phr_Config->choice.setup->dummy=false; + mac_CellGroupConfig->phr_Config->choice.setup->phr_Type2OtherCell = false; + mac_CellGroupConfig->phr_Config->choice.setup->phr_ModeOtherCG = NR_PHR_Config__phr_ModeOtherCG_real; + mac_CellGroupConfig->skipUplinkTxDynamic=false; + mac_CellGroupConfig->ext1 = NULL; secondaryCellGroup->physicalCellGroupConfig = calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig)); secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH=NULL; secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH=NULL; @@ -1176,6 +1076,14 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL; + mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); + mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); + schedulingrequestlist->schedulingRequestId = 0; + schedulingrequestlist->sr_ProhibitTimer = NULL; + schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; + ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig)); NR_PUSCH_ServingCellConfig_t *pusch_scc = calloc(1,sizeof(*pusch_scc)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->present = NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup; From 9150dc8c50c7433cdf2f9aabe63c1181c0a6176d Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 19 May 2022 14:48:45 +0200 Subject: [PATCH 61/84] applying review comment --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index d9e4658be2..8444544ede 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1810,7 +1810,7 @@ void fill_initial_SpCellConfig(int uid, csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; + *ssbres00 = 0; ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); csires1->bwp_Id = 0; csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; @@ -1830,8 +1830,8 @@ void fill_initial_SpCellConfig(int uid, } NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=0; - pucchcsires1->pucch_Resource=1; + pucchcsires1->uplinkBandwidthPartId = 0; + pucchcsires1->pucch_Resource = *pucch_Config->resourceSetToAddModList->list.array[1]->resourceList.list.array[0]; csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; if (pdsch_AntennaPorts > 1) { From fcfc7a90e87e476ded76f8211192bdd13622e0a3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 20 May 2022 13:56:12 +0200 Subject: [PATCH 62/84] fix for asan assertion --- openair1/PHY/INIT/nr_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index c7638bab0f..c68d782939 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -544,8 +544,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->nr_gold_pdsch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***)); uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs; - // ceil(((NB_RB*6(k)*2(QPSK)/32) // 3 RE *2(QPSK) - int pdsch_dmrs_init_length = ((fp->N_RB_DL*12)>>5)+1; + // ceil(((NB_RB*12(k)*2(QPSK)/32) // 3 RE *2(QPSK) + int pdsch_dmrs_init_length = ((fp->N_RB_DL*24)>>5)+1; for (int slot=0; slotslots_per_frame; slot++) { pdsch_dmrs[slot] = (uint32_t ***)malloc16(fp->symbols_per_slot*sizeof(uint32_t **)); AssertFatal(pdsch_dmrs[slot]!=NULL, "NR init: pdsch_dmrs for slot %d - malloc failed\n", slot); From a724c1febcc222641fb5e73b6d5fc823aa2bdadb Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 20 May 2022 15:09:25 +0200 Subject: [PATCH 63/84] starting timer for msg4 at transmission --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 18 ++++-------------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9ac9f0d880..15800326d6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1961,6 +1961,10 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; } else { + const NR_ServingCellConfig_t *servingCellConfig = ra->CellGroup ? ra->CellGroup->spCellConfig->spCellConfigDedicated : NULL; + uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; + sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %d with %d ms\n", frameP, slotP, UE_id, delay_ms); ra->state = WAIT_Msg4_ACK; LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); } @@ -1985,20 +1989,6 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); UE_info->active[UE_id] = true; UE_info->Msg4_ACKed[UE_id] = true; - - // Pause scheduling according to: - // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; - const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_ServingCellConfig_t *servingCellConfig = UE_info->CellGroup[UE_id] ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - common_channels->ServingCellConfigCommon, - sib1); - uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? - NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %d with %d ms\n", frame, slot, UE_id, delay_ms); } else { LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) RA Procedure failed at Msg4!\n", UE_id, ra->rnti); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a29aa8018c..5439a66170 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1909,7 +1909,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1) continue; + if (sched_ctrl->ul_failure==1 || sched_ctrl->rrc_processing_timer>0) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; From b96df49e15c311e78fcc78a762853668f0acfed0 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 1 Jun 2022 17:09:08 +0200 Subject: [PATCH 64/84] postpone initialization of UL_tti_req_ahead to when sl_ahead is available --- openair1/PHY/INIT/nr_init_ru.c | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 15 +-------------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 3 +++ .../LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 16 ++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 ++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 0e7c29800a..6aa42b1b10 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -60,7 +60,7 @@ int nr_phy_init_RU(RU_t *ru) { for (i=0; inb_tx; i++) { // Allocate 10 subframes of I/Q TX signal data (time) if not - ru->common.txdata[i] = (int32_t*)malloc16_clear( ru->sf_extension + (fp->samples_per_frame*sizeof(int32_t) )); + ru->common.txdata[i] = (int32_t*)malloc16_clear((ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t)); LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes,sf_extension %d)\n",i,ru->common.txdata[i], (ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t),ru->sf_extension); ru->common.txdata[i] = &ru->common.txdata[i][ru->sf_extension]; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 0e55b519ab..9273a24aa0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -462,8 +462,7 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_S return -1; } NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; - const uint16_t sf_ahead = 6/(0x01<0); - const uint16_t sl_ahead = sf_ahead * (0x01<if_inst->sl_ahead; sched_ctrl->rrc_processing_timer = (rrc_reconfiguration_delay<rnti, rrc_reconfiguration_delay); @@ -486,19 +485,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (scc != NULL ) { AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present); - /* dimension UL_tti_req_ahead for number of slots in frame */ const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - RC.nrmac[Mod_idP]->UL_tti_req_ahead[0] = calloc(n, sizeof(nfapi_nr_ul_tti_request_t)); - AssertFatal(RC.nrmac[Mod_idP]->UL_tti_req_ahead[0], - "could not allocate memory for RC.nrmac[]->UL_tti_req_ahead[]\n"); - /* fill in slot/frame numbers: slot is fixed, frame will be updated by scheduler - * consider that scheduler runs sl_ahead: the first sl_ahead slots are - * already "in the past" and thus we put frame 1 instead of 0! */ - for (int i = 0; i < n; ++i) { - nfapi_nr_ul_tti_request_t *req = &RC.nrmac[Mod_idP]->UL_tti_req_ahead[0][i]; - req->SFN = i < (RC.nrmac[Mod_idP]->if_inst->sl_ahead-1); - req->Slot = i; - } RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL = calloc(n * MAX_BWP_SIZE, sizeof(uint16_t)); AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index d7e2c78c35..25a307e804 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -68,6 +68,9 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc = gNB->common_channels->ServingCellConfigCommon; const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + if(gNB->init_UL_tti_req_ahead == false) + UL_tti_req_ahead_initialization(gNB, scc, num_slots); + nfapi_nr_dl_tti_request_t *DL_req = &gNB->DL_req[0]; nfapi_nr_dl_tti_pdcch_pdu_rel15_t **pdcch = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t **)gNB->pdcch_pdu_idx[CC_idP]; nfapi_nr_ul_tti_request_t *future_ul_tti_req = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 65d2ce09c5..eb0397866d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2996,3 +2996,19 @@ void schedule_nr_bwp_switch(module_id_t module_id, } } } + +void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n) { + + gNB->UL_tti_req_ahead[0] = calloc(n, sizeof(nfapi_nr_ul_tti_request_t)); + AssertFatal(gNB->UL_tti_req_ahead[0], + "could not allocate memory for RC.nrmac[]->UL_tti_req_ahead[]\n"); + /* fill in slot/frame numbers: slot is fixed, frame will be updated by scheduler + * consider that scheduler runs sl_ahead: the first sl_ahead slots are + * already "in the past" and thus we put frame 1 instead of 0! */ + for (int i = 0; i < n; ++i) { + nfapi_nr_ul_tti_request_t *req = &gNB->UL_tti_req_ahead[0][i]; + req->SFN = i < (gNB->if_inst->sl_ahead-1); + req->Slot = i; + } + gNB->init_UL_tti_req_ahead = true; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index f3dd5208d6..4fb51cd00b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -532,6 +532,8 @@ int get_mcs_from_bler(const NR_bler_options_t *bler_options, int max_mcs, frame_t frame); +void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n); + void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP); void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 974d6dff4a..63bf7b0595 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -850,6 +850,7 @@ typedef struct gNB_MAC_INST_s { uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; + bool init_UL_tti_req_ahead; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ From 894c45eae5020ddc970fa596e24499d7c5c71a9b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 9 Jun 2022 10:20:39 +0200 Subject: [PATCH 65/84] Add comment to fix fill_mastercellGroupConfig() --- openair2/RRC/NR/rrc_gNB.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 7faadcba4a..7632abd5cd 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1008,6 +1008,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( memset(buffer, 0, sizeof(buffer)); if(cell_groupConfig_from_DU == NULL){ cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + // FIXME: fill_mastercellGroupConfig() won't fill the right priorities or + // bearer IDs for the DRBs fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup, rrc->um_on_default_drb, (drb_id_to_setup_start < 2) ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); } else{ @@ -3478,6 +3480,8 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); if (req->srbs_to_be_setup_length > 0 || req->drbs_to_be_setup_length>0) + // FIXME: fill_mastercellGroupConfig() won't fill the right priorities or + // bearer IDs for the DRBs fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, rrc->um_on_default_drb, SRB2_config ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); apply_macrlc_config(rrc, ue_context_p, &ctxt); From 8adcf8368a68bbbc039b5acf1a3b0fd45287b626 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 9 Jun 2022 14:48:42 +0200 Subject: [PATCH 66/84] reverting activation of timer at transmission --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 89549b5466..2ea4328b17 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1963,10 +1963,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; } else { - const NR_ServingCellConfig_t *servingCellConfig = ra->CellGroup ? ra->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE 0x%04x with %d ms\n", frameP, slotP, UE->rnti, delay_ms); ra->state = WAIT_Msg4_ACK; LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); } @@ -1991,6 +1987,19 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram LOG_A(NR_MAC, "(UE RNTI 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", ra->rnti); UE->Msg4_ACKed = true; + // Pause scheduling according to: + // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs + const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; + const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + const NR_ServingCellConfig_t *servingCellConfig = UE_info->CellGroup[UE_id] ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated : NULL; + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, + common_channels->ServingCellConfigCommon, + sib1); + uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? + NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; + + sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %d with %d ms\n", frame, slot, UE_id, delay_ms); } else { LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); } From 33b69bdf304451fc2942548524b55d710b085a5b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 13 Jun 2022 18:28:07 +0200 Subject: [PATCH 67/84] nr rlc: bugfix: use hard-coded mapping between drb ID and mac lcid This will probably impact negatively the Accelleran interoperability but the previous version is not correct and breaks the oai nr ue. To be checked in a CU/DU scenario with Accelleran. --- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 29aed5d042..4bd4ea75fd 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -165,7 +165,7 @@ void mac_rlc_data_ind ( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; default: rb = NULL; break; } @@ -206,7 +206,7 @@ tbs_size_t mac_rlc_data_req( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; default: rb = NULL; LOG_E(RLC, "In %s:%d:%s: data request for unknown RB with LCID 0x%02x !\n", __FILE__, __LINE__, __FUNCTION__, channel_idP); @@ -254,7 +254,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; default: rb = NULL; break; } @@ -317,7 +317,7 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; //4 + case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; default: rb = NULL; break; } @@ -410,7 +410,7 @@ int nr_rlc_get_available_tx_space( switch (channel_idP) { case 1 ... 3: rb = ue->srb[channel_idP - 1]; break; - case 4 ... 8: rb = ue->drb[channel_idP - 1]; break; + case 4 ... 8: rb = ue->drb[channel_idP - 4]; break; default: rb = NULL; break; } @@ -780,7 +780,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; int drb_id = s->drb_Identity; - //int channel_id = rlc_BearerConfig->logicalChannelIdentity; + int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; int t_status_prohibit; @@ -797,11 +797,11 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ exit(1); } - /*if (channel_id != drb_id + 3) { + if (channel_id != drb_id + 3) { LOG_E(RLC, "%s:%d:%s: todo, remove this limitation\n", __FILE__, __LINE__, __FUNCTION__); exit(1); - }*/ + } logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; @@ -874,11 +874,11 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ exit(1); } - /*if (channel_id != drb_id + 3) { + if (channel_id != drb_id + 3) { LOG_E(RLC, "%s:%d:%s: todo, remove this limitation\n", __FILE__, __LINE__, __FUNCTION__); exit(1); - }*/ + } logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; From 630f8ac2b1b10917a881077edff04573f2c05bfb Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Tue, 14 Jun 2022 12:52:01 -0700 Subject: [PATCH 68/84] Putting all CM code in one file This commit includes reorganization of all of the SISO/MIMO channel modelling support being moved into a single CM file. Furthermore, it includes a bug fix for the number of MCS simulation tables (29 total, 0-28). --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/defs_common.h | 2 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 255 +----------------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 37 +-- openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c | 183 +++++++++++++ openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h | 68 +++++ openair2/PHY_INTERFACE/phy_stub_UE.c | 2 +- openair2/PHY_INTERFACE/phy_stub_UE.h | 2 +- 8 files changed, 258 insertions(+), 292 deletions(-) create mode 100644 openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c create mode 100644 openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c08d9378b8..84a98a300e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1926,6 +1926,7 @@ set (MAC_SRC_UE set (MAC_NR_SRC_UE ${NR_UE_PHY_INTERFACE_DIR}/NR_IF_Module.c + ${NR_UE_PHY_INTERFACE_DIR}/NR_Packet_Drop.c ${NR_UE_MAC_DIR}/config_ue.c ${NR_UE_MAC_DIR}/mac_vars.c ${NR_UE_MAC_DIR}/main_ue_nr.c diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index d13fe260de..47e17cc935 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -907,7 +907,7 @@ typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_rela -#define MCS_COUNT 28 +#define MCS_COUNT 29 #define MCS_TABLE_LENGTH_MAX 64 diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index b8b79f8399..b6f760a86a 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -66,17 +66,6 @@ queue_t nr_tx_req_queue; queue_t nr_ul_dci_req_queue; queue_t nr_ul_tti_req_queue; -static slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; - -//static int get_mcs_from_sinr(float sinr); -//static int get_cqi_from_mcs(void); -static void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int sf, int index); -//static bool did_drop_transport_block(int slot, uint16_t rnti); -static float get_bler_val(uint8_t mcs, int sinr); -static bool should_drop_transport_block(int slot, uint16_t rnti); -static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request); -static inline bool is_channel_modeling(void); - void nrue_init_standalone_socket(int tx_port, int rx_port) { { @@ -939,7 +928,7 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea return; } -static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request) +void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request) { int count_sent = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(0); @@ -1343,245 +1332,3 @@ void RCconfig_nr_ue_L1(void) { } } } - -/* -static int get_mcs_from_sinr(float sinr) -{ - if (sinr < (nr_bler_data[0].bler_table[0][0])) - { - LOG_D(NR_MAC, "The SINR found is smaller than first MCS table\n"); - return 0; - } - - if (sinr > (nr_bler_data[NR_NUM_MCS-1].bler_table[nr_bler_data[NR_NUM_MCS-1].length - 1][0])) - { - LOG_D(NR_MAC, "The SINR found is larger than last MCS table\n"); - return NR_NUM_MCS-1; - } - - for (int n = NR_NUM_MCS-1; n >= 0; n--) - { - CHECK_INDEX(nr_bler_data, n); - float largest_sinr = (nr_bler_data[n].bler_table[nr_bler_data[n].length - 1][0]); - float smallest_sinr = (nr_bler_data[n].bler_table[0][0]); - if (sinr < largest_sinr && sinr > smallest_sinr) - { - LOG_D(NR_MAC, "The SINR found in MCS %d table\n", n); - return n; - } - } - LOG_E(NR_MAC, "Unable to get an MCS value.\n"); - abort(); -} -*/ - -/* -static int get_cqi_from_mcs(void) -{ - static const int mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15}; - assert(NUM_ELEMENTS(mcs_to_cqi) == NR_NUM_MCS); - int slot = 0; - while (slot < NUM_NFAPI_SLOT) - { - if (slot_rnti_mcs[slot].latest) - { - int num_pdus = slot_rnti_mcs[slot].num_pdus; - if (num_pdus <= 0) - { - LOG_E(NR_MAC, "%s: slot_rnti_mcs[%d].num_pdus = 0\n", __FUNCTION__, slot); - abort(); - } - - CHECK_INDEX(slot_rnti_mcs[slot].mcs, num_pdus); - int mcs = get_mcs_from_sinr(slot_rnti_mcs[slot].sinr); - CHECK_INDEX(mcs_to_cqi, mcs); - int cqi = mcs_to_cqi[mcs]; - LOG_D(NR_MAC, "SINR: %f -> MCS: %d -> CQI: %d\n", slot_rnti_mcs[slot].sinr, mcs, cqi); - return cqi; - } - slot++; - } - LOG_E(NR_MAC, "Unable to get CQI value because no MCS found\n"); - abort(); -} -*/ - -static void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int slot, int index) -{ - if (pdu == NULL) - { - LOG_E(NR_MAC,"PDU NULL\n"); - abort(); - } - - /* This function is executed for every pdsch pdu type in a dl_tti_request. We save - the assocaited MCS and RNTI value for each. The 'index' passed in is a count of - how many times we have called this function for a particular dl_tti_request. It - allows us to save MCS/RNTI data in correct indicies when multiple pdsch pdu's are received.*/ - for (int i = 0; i < NUM_NFAPI_SLOT; i++) - { - slot_rnti_mcs[i].latest = false; - } - - CHECK_INDEX(slot_rnti_mcs[slot].rnti, index); - CHECK_INDEX(slot_rnti_mcs[slot].mcs, index); - CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, index); - slot_rnti_mcs[slot].rnti[index] = pdu->rnti; - slot_rnti_mcs[slot].mcs[index] = pdu->mcsIndex[0]; - slot_rnti_mcs[slot].rvIndex[index] = pdu->rvIndex[0]; - slot_rnti_mcs[slot].drop_flag[index] = false; - slot_rnti_mcs[slot].num_pdus = index+1; //index starts at 0 so we incrament to get num of pdus - slot_rnti_mcs[slot].latest = true; - LOG_D(NR_MAC, "Adding MCS %d and RNTI %x for slot_rnti_mcs[%d]\n", slot_rnti_mcs[slot].mcs[index], slot_rnti_mcs[slot].rnti[index], slot); - - return; -} - -/* -static bool did_drop_transport_block(int slot, uint16_t rnti) -{ - int num_pdus = slot_rnti_mcs[slot].num_pdus; - if (num_pdus <= 0) - { - LOG_E(MAC, "Problem, the PDU size is <= 0. We dropped this packet\n"); - return true; - } - CHECK_INDEX(slot_rnti_mcs[slot].rnti, num_pdus); - CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, num_pdus); - for (int n = 0; n < num_pdus; n++) - { - if (slot_rnti_mcs[slot].rnti[n] == rnti && slot_rnti_mcs[slot].drop_flag[n]) - { - return true; - } - } - return false; -} -*/ - -static float get_bler_val(uint8_t mcs, int sinr) -{ - // 4th col = dropped packets, 5th col = total packets - float bler_val = 0.0; - CHECK_INDEX(nr_bler_data, mcs); - LOG_D(NR_MAC, "sinr %d min %d max %d\n", sinr, - (int)(nr_bler_data[mcs].bler_table[0][0] * 10), - (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10) - ); - - if (sinr < (int)(nr_bler_data[mcs].bler_table[0][0] * 10)) - { - LOG_D(NR_MAC, "MCS %d table. SINR is smaller than lowest SINR, bler_val is set based on lowest SINR in table\n", mcs); - bler_val = nr_bler_data[mcs].bler_table[0][4] / nr_bler_data[mcs].bler_table[0][5]; - return bler_val; - } - if (sinr > (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10)) - { - LOG_D(NR_MAC, "MCS %d table. SINR is greater than largest SINR. bler_val is set based on largest SINR in table\n", mcs); - bler_val = nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][4] / nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][5]; - return bler_val; - } - // Loop through bler table to find sinr_index - for (int i = 0; i < nr_bler_data[mcs].length; i++) - { - int temp_sinr = (int)(nr_bler_data[mcs].bler_table[i][0] * 10); - if (temp_sinr == sinr) - { - bler_val = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; - return bler_val; - } - // Linear interpolation when SINR is between indices - if (temp_sinr > sinr) - { - float bler_val1 = nr_bler_data[mcs].bler_table[i - 1][4] / nr_bler_data[mcs].bler_table[i - 1][5]; - float bler_val2 = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; - LOG_D(NR_MAC, "sinr %d min %f max %f\n", sinr, bler_val1, bler_val2); - return ((bler_val1 + bler_val2) / 2); - } - } - LOG_E(NR_MAC, "NO SINR INDEX FOUND!\n"); - abort(); - -} - -static inline bool is_channel_modeling(void) -{ - /* TODO: For now we enable channel modeling based on the node_number. - Replace with a command line option to enable/disable channel modeling. - The LTE UE will crash when channel modeling is conducted for NSA - mode. It does not crash for LTE mode. We have not implemented channel - modeling for NSA mode yet. For now, we ensure only do do channel modeling - in LTE/NR mode. */ - return get_softmodem_params()->node_number == 0 && !get_softmodem_params()->nsa; -} - -static bool should_drop_transport_block(int slot, uint16_t rnti) -{ - if (!is_channel_modeling()) - { - return false; - } - - /* We want to avoid dropping setup messages because this would be pathological. */ - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - if (mac->ra.ra_state < RA_SUCCEEDED) - { - LOG_D(NR_MAC, "Not dropping because MAC state: %d", mac->ra.ra_state); - return false; - } - - /* Get block error rate (bler_val) from table based on every saved - MCS and SINR to be used as the cutoff rate for dropping packets. - Generate random uniform vairable to compare against bler_val. */ - int num_pdus = slot_rnti_mcs[slot].num_pdus; - assert(slot < 20 && slot >= 0); - LOG_D(NR_MAC, "rnti: %x num_pdus %d state %d slot %u sinr %f\n", - rnti, num_pdus, mac->ra.ra_state, slot, slot_rnti_mcs[slot].sinr); - assert(num_pdus > 0); - CHECK_INDEX(slot_rnti_mcs[slot].rnti, num_pdus); - CHECK_INDEX(slot_rnti_mcs[slot].mcs, num_pdus); - CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, num_pdus); - int n = 0; - uint8_t mcs = 99; - for (n = 0; n < num_pdus; n++) - { - if (slot_rnti_mcs[slot].rnti[n] == rnti) - { - mcs = slot_rnti_mcs[slot].mcs[n]; - } - if (mcs != 99) - { - /* Use MCS to get the bler value. Since there can be multiple MCS - values for a particular slot, we verify that all PDUs are not - flagged for drop before returning. If even one is flagged for drop - we return immediately because we drop the entire packet. */ - - LOG_D(NR_MAC, "rnti: %x mcs %u slot %u sinr %f\n", - slot_rnti_mcs[slot].rnti[n], mcs, slot, slot_rnti_mcs[slot].sinr); - - float bler_val; - if (slot_rnti_mcs[slot].rvIndex[n] != 0) - bler_val = 0; - else - bler_val = get_bler_val(mcs, ((int)(slot_rnti_mcs[slot].sinr * 10))); - double drop_cutoff = ((double) rand() / (RAND_MAX)); - assert(drop_cutoff <= 1); - LOG_D(NR_MAC, "SINR = %f, Bler_val = %f, MCS = %"PRIu8"\n", slot_rnti_mcs[slot].sinr, bler_val, slot_rnti_mcs[slot].mcs[n]); - if (drop_cutoff <= bler_val) - { - slot_rnti_mcs[slot].drop_flag[n] = true; - LOG_T(NR_MAC, "We are dropping this packet. Bler_val = %f, MCS = %"PRIu8", slot = %d\n", bler_val, slot_rnti_mcs[slot].mcs[n], slot); - return slot_rnti_mcs[slot].drop_flag[n]; - } - } - - } - - if (mcs == 99) - { - LOG_E(NR_MAC, "NO MCS Found for rnti %x. slot_rnti_mcs[%d].mcs[%d] \n", rnti, slot, n); - abort(); - } - return false; -} diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 45d1a071ca..f663c17d10 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -40,45 +40,12 @@ #include "openair2/PHY_INTERFACE/queue_t.h" #include "nfapi_nr_interface_scf.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" +#include "NR_Packet_Drop.h" -#define NR_NUM_MCS 29 -#define NUM_SINR 100 -#define NUM_BLER_COL 13 -#define NUM_NFAPI_SLOT 20 -#define NR_NUM_LAYER 1 +extern slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; -typedef struct nr_phy_channel_params_t -{ - uint16_t sfn_slot; - uint16_t message_id; - uint16_t nb_of_sinrs; - float sinr[NR_NUM_LAYER]; - // Incomplete, need all channel parameters -} nr_phy_channel_params_t; - -typedef struct -{ - uint8_t slot; - uint16_t rnti[256]; - uint8_t mcs[256]; - uint8_t rvIndex[256]; - float sinr; - uint16_t num_pdus; - bool drop_flag[256]; - bool latest; - -} slot_rnti_mcs_s; - -typedef struct -{ - uint16_t length; - float bler_table[NUM_SINR][NUM_BLER_COL]; -} nr_bler_struct; - -extern nr_bler_struct nr_bler_data[NR_NUM_MCS]; - typedef enum { ONLY_PUSCH, NOT_PUSCH, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c new file mode 100644 index 0000000000..41d27bda80 --- /dev/null +++ b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c @@ -0,0 +1,183 @@ +/* + * 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 +#include "openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h" +#include "executables/softmodem-common.h" +#include "NR_MAC_UE/mac_proto.h" + +slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; +void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int slot, int index) +{ + if (pdu == NULL) + { + LOG_E(NR_MAC,"PDU NULL\n"); + abort(); + } + + /* This function is executed for every pdsch pdu type in a dl_tti_request. We save + the assocaited MCS and RNTI value for each. The 'index' passed in is a count of + how many times we have called this function for a particular dl_tti_request. It + allows us to save MCS/RNTI data in correct indicies when multiple pdsch pdu's are received.*/ + for (int i = 0; i < NUM_NFAPI_SLOT; i++) + { + slot_rnti_mcs[i].latest = false; + } + + CHECK_INDEX(slot_rnti_mcs[slot].rnti, index); + CHECK_INDEX(slot_rnti_mcs[slot].mcs, index); + CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, index); + slot_rnti_mcs[slot].rnti[index] = pdu->rnti; + slot_rnti_mcs[slot].mcs[index] = pdu->mcsIndex[0]; + slot_rnti_mcs[slot].rvIndex[index] = pdu->rvIndex[0]; + slot_rnti_mcs[slot].drop_flag[index] = false; + slot_rnti_mcs[slot].num_pdus = index+1; //index starts at 0 so we incrament to get num of pdus + slot_rnti_mcs[slot].latest = true; + LOG_D(NR_MAC, "Adding MCS %d and RNTI %x for slot_rnti_mcs[%d]\n", slot_rnti_mcs[slot].mcs[index], slot_rnti_mcs[slot].rnti[index], slot); + + return; +} + +float get_bler_val(uint8_t mcs, int sinr) +{ + // 4th col = dropped packets, 5th col = total packets + nr_bler_struct nr_bler_data[NR_NUM_MCS]; + float bler_val = 0.0; + CHECK_INDEX(nr_bler_data, mcs); + LOG_D(NR_MAC, "sinr %d min %d max %d\n", sinr, + (int)(nr_bler_data[mcs].bler_table[0][0] * 10), + (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10) + ); + + if (sinr < (int)(nr_bler_data[mcs].bler_table[0][0] * 10)) + { + LOG_D(NR_MAC, "MCS %d table. SINR is smaller than lowest SINR, bler_val is set based on lowest SINR in table\n", mcs); + bler_val = nr_bler_data[mcs].bler_table[0][4] / nr_bler_data[mcs].bler_table[0][5]; + return bler_val; + } + if (sinr > (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10)) + { + LOG_D(NR_MAC, "MCS %d table. SINR is greater than largest SINR. bler_val is set based on largest SINR in table\n", mcs); + bler_val = nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][4] / nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][5]; + return bler_val; + } + // Loop through bler table to find sinr_index + for (int i = 0; i < nr_bler_data[mcs].length; i++) + { + int temp_sinr = (int)(nr_bler_data[mcs].bler_table[i][0] * 10); + if (temp_sinr == sinr) + { + bler_val = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; + return bler_val; + } + // Linear interpolation when SINR is between indices + if (temp_sinr > sinr) + { + float bler_val1 = nr_bler_data[mcs].bler_table[i - 1][4] / nr_bler_data[mcs].bler_table[i - 1][5]; + float bler_val2 = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; + LOG_D(NR_MAC, "sinr %d min %f max %f\n", sinr, bler_val1, bler_val2); + return ((bler_val1 + bler_val2) / 2); + } + } + LOG_E(NR_MAC, "NO SINR INDEX FOUND!\n"); + abort(); + +} + +bool is_channel_modeling(void) +{ + /* TODO: For now we enable channel modeling based on the node_number. + Replace with a command line option to enable/disable channel modeling. + The LTE UE will crash when channel modeling is conducted for NSA + mode. It does not crash for LTE mode. We have not implemented channel + modeling for NSA mode yet. For now, we ensure only do do channel modeling + in LTE/NR mode. */ + return get_softmodem_params()->node_number == 0 && !get_softmodem_params()->nsa; +} + +bool should_drop_transport_block(int slot, uint16_t rnti) +{ + if (!is_channel_modeling()) + { + return false; + } + + /* We want to avoid dropping setup messages because this would be pathological. */ + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + if (mac->ra.ra_state < RA_SUCCEEDED) + { + LOG_D(NR_MAC, "Not dropping because MAC state: %d", mac->ra.ra_state); + return false; + } + + /* Get block error rate (bler_val) from table based on every saved + MCS and SINR to be used as the cutoff rate for dropping packets. + Generate random uniform vairable to compare against bler_val. */ + int num_pdus = slot_rnti_mcs[slot].num_pdus; + assert(slot < 20 && slot >= 0); + LOG_D(NR_MAC, "rnti: %x num_pdus %d state %d slot %u sinr %f\n", + rnti, num_pdus, mac->ra.ra_state, slot, slot_rnti_mcs[slot].sinr); + assert(num_pdus > 0); + CHECK_INDEX(slot_rnti_mcs[slot].rnti, num_pdus); + CHECK_INDEX(slot_rnti_mcs[slot].mcs, num_pdus); + CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, num_pdus); + int n = 0; + uint8_t mcs = 99; + for (n = 0; n < num_pdus; n++) + { + if (slot_rnti_mcs[slot].rnti[n] == rnti) + { + mcs = slot_rnti_mcs[slot].mcs[n]; + } + if (mcs != 99) + { + /* Use MCS to get the bler value. Since there can be multiple MCS + values for a particular slot, we verify that all PDUs are not + flagged for drop before returning. If even one is flagged for drop + we return immediately because we drop the entire packet. */ + + LOG_D(NR_MAC, "rnti: %x mcs %u slot %u sinr %f\n", + slot_rnti_mcs[slot].rnti[n], mcs, slot, slot_rnti_mcs[slot].sinr); + + float bler_val; + if (slot_rnti_mcs[slot].rvIndex[n] != 0) + bler_val = 0; + else + bler_val = get_bler_val(mcs, ((int)(slot_rnti_mcs[slot].sinr * 10))); + double drop_cutoff = ((double) rand() / (RAND_MAX)); + assert(drop_cutoff <= 1); + LOG_D(NR_MAC, "SINR = %f, Bler_val = %f, MCS = %"PRIu8"\n", slot_rnti_mcs[slot].sinr, bler_val, slot_rnti_mcs[slot].mcs[n]); + if (drop_cutoff <= bler_val) + { + slot_rnti_mcs[slot].drop_flag[n] = true; + LOG_T(NR_MAC, "We are dropping this packet. Bler_val = %f, MCS = %"PRIu8", slot = %d\n", bler_val, slot_rnti_mcs[slot].mcs[n], slot); + return slot_rnti_mcs[slot].drop_flag[n]; + } + } + + } + + if (mcs == 99) + { + LOG_E(NR_MAC, "NO MCS Found for rnti %x. slot_rnti_mcs[%d].mcs[%d] \n", rnti, slot, n); + abort(); + } + return false; +} diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h new file mode 100644 index 0000000000..549eb5c2e3 --- /dev/null +++ b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h @@ -0,0 +1,68 @@ +/* + * 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 + */ +#ifndef __NR_CHAN_MODEL_H__ +#define __NR_CHAN_MODEL_H__ + +#include +#include +#include +#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" + +#define NR_NUM_MCS 29 +#define NUM_SINR 100 +#define NUM_BLER_COL 13 +#define NUM_NFAPI_SLOT 20 +#define NR_NUM_LAYER 1 +#define MAX_CHAN_PARAMS 256 + +typedef struct nr_phy_channel_params_t +{ + uint16_t sfn_slot; + uint16_t message_id; + uint16_t nb_of_sinrs; + float sinr[NR_NUM_LAYER]; +} nr_phy_channel_params_t; + +typedef struct +{ + uint8_t slot; + uint16_t rnti[MAX_CHAN_PARAMS]; + uint8_t mcs[MAX_CHAN_PARAMS]; + uint8_t rvIndex[MAX_CHAN_PARAMS]; + float sinr; + uint16_t num_pdus; + bool drop_flag[MAX_CHAN_PARAMS]; + bool latest; +} slot_rnti_mcs_s; + +typedef struct +{ + uint16_t length; + float bler_table[NUM_SINR][NUM_BLER_COL]; +} nr_bler_struct; + +void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int sf, int index); +void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request); +float get_bler_val(uint8_t mcs, int sinr); +bool should_drop_transport_block(int slot, uint16_t rnti); +bool is_channel_modeling(void); + +#endif diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index c4650f18f3..cd57ea9ff1 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -1956,7 +1956,7 @@ static int get_mcs_from_sinr(float sinr) static int get_cqi_from_mcs(void) { - static const int mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15}; + static const int mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15}; assert(NUM_ELEMENTS(mcs_to_cqi) == NUM_MCS); int sf = 0; while(sf < NUM_NFAPI_SUBFRAME) diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h index d68d1dffdd..fe0e7be12e 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.h +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -21,7 +21,7 @@ //#include "openair1/PHY/LTE_TRANSPORT/defs.h" #include "queue_t.h" -#define NUM_MCS 28 +#define NUM_MCS 29 #define NUM_SINR 100 #define NUM_BLER_COL 13 #define LTE_NUM_LAYER 1 From 2b38c78588cb21d9f8fcb2688fc60d0709c5f27e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sun, 12 Jun 2022 16:52:01 +0200 Subject: [PATCH 69/84] Add fedora36 to supported distros --- cmake_targets/tools/build_helper | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 179e2de428..525edfe5fc 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -109,6 +109,7 @@ check_supported_distribution() { "ubuntu18.04") return 0 ;; "ubuntu16.04") return 0 ;; "fedora35") return 0 ;; + "fedora36") return 0 ;; "rhel7") return 0 ;; "rhel7.6") return 0 ;; "rhel7.7") return 0 ;; From dab905519be98c92061a32ccb0f9203becc2b1c2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sun, 12 Jun 2022 17:11:36 +0200 Subject: [PATCH 70/84] Remove nscd from additional packages nscd (Name service cache daemon) is not needed for running OAI --- cmake_targets/tools/build_helper | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 525edfe5fc..95f237ab33 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -624,7 +624,6 @@ check_install_additional_tools (){ android-tools-adb \ wvdial \ sshpass \ - nscd \ bc \ ntp" elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then @@ -649,7 +648,6 @@ check_install_additional_tools (){ wvdial \ numpy \ sshpass \ - nscd \ python2-paramiko \ python-pyroute2 \ python-netifaces \ @@ -677,7 +675,6 @@ check_install_additional_tools (){ wvdial \ python-numpy \ sshpass \ - nscd \ python-paramiko \ python-pyroute2 \ python-netifaces \ From 4f44a1026b69b106a0fc48095c403f73f4d99de7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sun, 19 Jun 2022 18:01:58 +0200 Subject: [PATCH 71/84] Remove RHEL_RELEASE_CODE define --- openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 9 ++------- openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c | 5 ----- openair2/NETWORK_DRIVER/MESH/device.c | 6 +++--- openair2/NETWORK_DRIVER/UE_IP/device.c | 8 ++------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index 0b665737a7..fb7c920a1e 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -41,13 +41,8 @@ #include #include #include -#if RHEL_RELEASE_CODE >= 1796 - #include - #include -#else - #include - #include -#endif +#include +#include #include #include "linear_preprocessing_rec.h" diff --git a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c index 7d063e326e..59da43e564 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c @@ -14,13 +14,8 @@ data storage. */ #include #include #include -#if RHEL_RELEASE_CODE >= 1796 -#include -#include -#else #include #include -#endif //#define DEBUG_PREPROC diff --git a/openair2/NETWORK_DRIVER/MESH/device.c b/openair2/NETWORK_DRIVER/MESH/device.c index f63408259c..c1b5401011 100644 --- a/openair2/NETWORK_DRIVER/MESH/device.c +++ b/openair2/NETWORK_DRIVER/MESH/device.c @@ -198,7 +198,7 @@ int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) // End debug information netif_stop_queue(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE>=1796) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -267,7 +267,7 @@ void nas_tx_timeout(struct net_device *dev) printk("TX_TIMEOUT: begin\n"); // (struct nas_priv *)(dev->priv)->stats.tx_errors++; (priv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE>=1796) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -285,7 +285,7 @@ static const struct net_device_ops nasmesh_netdev_ops = { .ndo_set_mac_address = NULL, .ndo_set_config = nas_set_config, .ndo_do_ioctl = nas_CTL_ioctl, -#if (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE>=1797 && LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0)) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) .extended.ndo_change_mtu = nas_change_mtu, #else .ndo_change_mtu = nas_change_mtu, diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c index 0ff9a73925..fa762d1ba9 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ b/openair2/NETWORK_DRIVER/UE_IP/device.c @@ -239,7 +239,7 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) { // End debug information netif_stop_queue(dev_pP); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -315,7 +315,7 @@ void ue_ip_tx_timeout(struct net_device *dev_pP) printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__); // (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++; (priv_p->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -333,11 +333,7 @@ static const struct net_device_ops ue_ip_netdev_ops = { .ndo_set_mac_address = ue_ip_set_mac_address, .ndo_set_config = ue_ip_set_config, .ndo_do_ioctl = NULL, -#if (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1797) - .extended.ndo_change_mtu = ue_ip_change_mtu, -#else .ndo_change_mtu = ue_ip_change_mtu, -#endif .ndo_tx_timeout = ue_ip_tx_timeout, .ndo_change_rx_flags = ue_ip_change_rx_flags, }; From 2bed0352fd7330eddafb480cb258b81716b19faf Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sun, 19 Jun 2022 18:33:57 +0200 Subject: [PATCH 72/84] f1: remove hardcoded value, set to what is in develop --- openair2/F1AP/f1ap_du_task.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 4982f7617b..5212e325b3 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -126,7 +126,8 @@ void *F1AP_DU_task(void *arg) { LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n"); f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg); createF1inst(false, myInstance, msgSetup); - getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu("172.21.10.9",//"172.21.9.5", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" +printf("XXXXXXXXXXXXXXX old 172.21.6.9 new %s\n", msgSetup->CU_f1_ip_address.ipv4_address); + getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu(msgSetup->CU_f1_ip_address.ipv4_address, //"172.21.6.9", //"172.21.10.9",//"172.21.9.5", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" msgSetup->CUport, msgSetup->DU_f1_ip_address.ipv4_address, msgSetup->DUport); From 2124e43d3afca4440b5d5db90fe9f2079d898acf Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 20 Jun 2022 11:04:03 +0200 Subject: [PATCH 73/84] Correctly use RHEL_RELEASE_CODE for Fedora and RHEL This reverts commit 4f44a1026b69b106a0fc48095c403f73f4d99de7. --- openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 10 ++++++++-- .../PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c | 6 ++++++ openair2/NETWORK_DRIVER/MESH/device.c | 12 +++++++++--- openair2/NETWORK_DRIVER/UE_IP/device.c | 13 +++++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index fb7c920a1e..4ad27fcfbe 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -41,8 +41,14 @@ #include #include #include -#include -#include +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) + #include + #include +#else + #include + #include +#endif #include #include "linear_preprocessing_rec.h" diff --git a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c index 59da43e564..265e88dc39 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c @@ -14,8 +14,14 @@ data storage. */ #include #include #include +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) +#include +#include +#else #include #include +#endif //#define DEBUG_PREPROC diff --git a/openair2/NETWORK_DRIVER/MESH/device.c b/openair2/NETWORK_DRIVER/MESH/device.c index c1b5401011..08e1577cea 100644 --- a/openair2/NETWORK_DRIVER/MESH/device.c +++ b/openair2/NETWORK_DRIVER/MESH/device.c @@ -198,7 +198,9 @@ int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) // End debug information netif_stop_queue(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -267,7 +269,9 @@ void nas_tx_timeout(struct net_device *dev) printk("TX_TIMEOUT: begin\n"); // (struct nas_priv *)(dev->priv)->stats.tx_errors++; (priv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -285,7 +289,9 @@ static const struct net_device_ops nasmesh_netdev_ops = { .ndo_set_mac_address = NULL, .ndo_set_config = nas_set_config, .ndo_do_ioctl = nas_CTL_ioctl, -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) \ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,5) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) .extended.ndo_change_mtu = nas_change_mtu, #else .ndo_change_mtu = nas_change_mtu, diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c index fa762d1ba9..d124be07ae 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ b/openair2/NETWORK_DRIVER/UE_IP/device.c @@ -239,7 +239,9 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) { // End debug information netif_stop_queue(dev_pP); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -315,7 +317,9 @@ void ue_ip_tx_timeout(struct net_device *dev_pP) printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__); // (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++; (priv_p->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \\ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -333,7 +337,12 @@ static const struct net_device_ops ue_ip_netdev_ops = { .ndo_set_mac_address = ue_ip_set_mac_address, .ndo_set_config = ue_ip_set_config, .ndo_do_ioctl = NULL, +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,5) \ + && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) + .extended.ndo_change_mtu = ue_ip_change_mtu, +#else .ndo_change_mtu = ue_ip_change_mtu, +#endif .ndo_tx_timeout = ue_ip_tx_timeout, .ndo_change_rx_flags = ue_ip_change_rx_flags, }; From a4e2c2b799485008ace47c44837a6265bcc4832c Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 20 Jun 2022 11:58:06 +0200 Subject: [PATCH 74/84] addressing review --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 6 ++--- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- .../CONF/gnb.band66.tm1.25PRB.usrpn300.conf | 3 --- ....sa.band78.fr1.106PRB.usrpb210.4layer.conf | 27 ++----------------- ...gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf | 3 +-- ...gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf | 3 +-- 7 files changed, 8 insertions(+), 38 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 1f1b1ece8d..5ffccf28d3 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -344,7 +344,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, cfg->ssb_table.ssb_offset_point_a = absolute_diff/(12*scs_scaling) - 10; cfg->ssb_table.ssb_period = *scc->ssb_periodicityServingCell; - // NSA -> take ssb offset from SSC + // NSA -> take ssb offset from SCS cfg->ssb_table.ssb_subcarrier_offset = absolute_diff%(12*scs_scaling); switch (scc->ssb_PositionsInBurst->present) { diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 0e3bce7f24..2fd3357b53 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -343,14 +343,12 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, int pusch_AntennaPorts, uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); RC.nrmac[Mod_idP]->ssb_SubcarrierOffset = absolute_diff%(12*scs_scaling); - int sco; + int sco = 31; // no SIB1 if(get_softmodem_params()->sa) { sco = RC.nrmac[Mod_idP]->ssb_SubcarrierOffset; if(frequency_range == FR1) - sco = sco<ssb_config.scs_common.value; + sco <<= cfg->ssb_config.scs_common.value; // 38.211 section 7.4.3.1 in FR1 it is expresses in terms of 15kHz SCS } - else - sco = 31; // no SIB1 cfg->ssb_table.ssb_offset_point_a.value = absolute_diff/(12*scs_scaling) - 10; //absoluteFrequencySSB is the central frequency of SSB which is made by 20RBs in total cfg->ssb_table.ssb_offset_point_a.tl.tag = NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7d33f02dc0..bddc1509c5 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -236,7 +236,7 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { if (get_softmodem_params()->sa) { ssb_subcarrier_offset = absolute_diff%(12*scs_scaling); if(frequency_range == FR1) - ssb_subcarrier_offset = ssb_subcarrier_offset<<*scc->ssbSubcarrierSpacing; + ssb_subcarrier_offset <<= *scc->ssbSubcarrierSpacing; } mib->message.choice.mib->ssb_SubcarrierOffset = ssb_subcarrier_offset&15; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf index 6af1356088..022f17e490 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf @@ -21,9 +21,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf index 74f2f9c11c..8ff83b5d02 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf @@ -32,10 +32,9 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 4; + pdsch_AntennaPorts_XP = 2; + pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 4; - sib1_tda = 0; pdcch_ConfigSIB1 = ( { @@ -73,15 +72,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -136,19 +126,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf index 763396998d..1f1f64ce3f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf @@ -27,7 +27,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_XP = 1; pusch_AntennaPorts = 2; do_CSIRS = 0; @@ -318,4 +317,4 @@ log_config : rrc_log_level ="info"; ngap_log_level ="debug"; f1ap_log_level ="debug"; -}; \ No newline at end of file +}; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf index 3d93f2cfab..24090bef85 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf @@ -27,7 +27,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_XP = 1; pusch_AntennaPorts = 2; do_CSIRS = 0; @@ -318,4 +317,4 @@ log_config : rrc_log_level ="info"; ngap_log_level ="debug"; f1ap_log_level ="debug"; -}; \ No newline at end of file +}; From 0fe98c25a2e04c644d6aabdcef9ba192400c9e6f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 20 Jun 2022 13:34:54 +0200 Subject: [PATCH 75/84] Avoid RHEL_RELEASE_VERSION: not defined in Ubuntu --- openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 3 +-- .../PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c | 3 +-- openair2/NETWORK_DRIVER/MESH/device.c | 9 +++------ openair2/NETWORK_DRIVER/UE_IP/device.c | 11 ++++------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index 4ad27fcfbe..8f5e33d6e0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -41,8 +41,7 @@ #include #include #include -#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403 #include #include #else diff --git a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c index 265e88dc39..83c74389cf 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.c @@ -14,8 +14,7 @@ data storage. */ #include #include #include -#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403 #include #include #else diff --git a/openair2/NETWORK_DRIVER/MESH/device.c b/openair2/NETWORK_DRIVER/MESH/device.c index 08e1577cea..d86e32e561 100644 --- a/openair2/NETWORK_DRIVER/MESH/device.c +++ b/openair2/NETWORK_DRIVER/MESH/device.c @@ -199,8 +199,7 @@ int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) // End debug information netif_stop_queue(dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -270,8 +269,7 @@ void nas_tx_timeout(struct net_device *dev) // (struct nas_priv *)(dev->priv)->stats.tx_errors++; (priv->stats).tx_errors++; #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) netif_trans_update(dev); #else dev->trans_start = jiffies; @@ -290,8 +288,7 @@ static const struct net_device_ops nasmesh_netdev_ops = { .ndo_set_config = nas_set_config, .ndo_do_ioctl = nas_CTL_ioctl, #if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,5) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1797 && RHEL_RELEASE_CODE != 2403) .extended.ndo_change_mtu = nas_change_mtu, #else .ndo_change_mtu = nas_change_mtu, diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c index d124be07ae..bf858a0005 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ b/openair2/NETWORK_DRIVER/UE_IP/device.c @@ -240,8 +240,7 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) { // End debug information netif_stop_queue(dev_pP); #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -317,9 +316,8 @@ void ue_ip_tx_timeout(struct net_device *dev_pP) printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__); // (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++; (priv_p->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \\ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ + || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) netif_trans_update(dev_pP); #else dev_pP->trans_start = jiffies; @@ -337,8 +335,7 @@ static const struct net_device_ops ue_ip_netdev_ops = { .ndo_set_mac_address = ue_ip_set_mac_address, .ndo_set_config = ue_ip_set_config, .ndo_do_ioctl = NULL, -#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,5) \ - && RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(9,99) +#if defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1797 && RHEL_RELEASE_CODE != 2403 .extended.ndo_change_mtu = ue_ip_change_mtu, #else .ndo_change_mtu = ue_ip_change_mtu, From d0fa56b1de6f4ec4d44c38dad92b21a4a5185424 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 20 Jun 2022 15:15:11 +0200 Subject: [PATCH 76/84] compilation fix --- openair2/RRC/NR/rrc_gNB.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index ddefb76789..159640ba7a 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -809,6 +809,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( } if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { + gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; rrc_mac_config_req_gNB(rrc->module_id, rrc->configuration.ssb_SubcarrierOffset, rrc->configuration.pdsch_AntennaPorts, From 9c02189e64aa214dd1adc6d23c3638b2f9880a2b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 21 Jun 2022 08:54:41 +0200 Subject: [PATCH 77/84] Remove nr_bler_data from physims --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 -- openair1/SIMULATION/NR_PHY/prachsim.c | 2 -- openair1/SIMULATION/NR_PHY/ulsim.c | 2 -- 3 files changed, 6 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index bab67e4426..d319ac8a2b 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -242,8 +242,6 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } -nr_bler_struct nr_bler_data[NR_NUM_MCS]; - void processSlotTX(void *arg) {} //nFAPI P7 dummy functions to avoid linking errors diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 33717c944d..91a8265ff1 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -227,8 +227,6 @@ nrUE_params_t *get_nrUE_params(void) { return &nrUE_params; } -nr_bler_struct nr_bler_data[NR_NUM_MCS]; - void processSlotTX(void *arg) {} int main(int argc, char **argv){ diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 2a3730c1d4..8a9b4a7a46 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -225,8 +225,6 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } -nr_bler_struct nr_bler_data[NR_NUM_MCS]; - //nFAPI P7 dummy functions int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } From 2659dce8b830ad9549022ada5b7bfa19cc89dd31 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 21 Jun 2022 13:49:31 +0200 Subject: [PATCH 78/84] removing flag init_UL_tti_req_ahead --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 3 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 11 ++++++----- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 92867602c8..c87aa68f75 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -68,8 +68,7 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc = gNB->common_channels->ServingCellConfigCommon; const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - if(gNB->init_UL_tti_req_ahead == false) - UL_tti_req_ahead_initialization(gNB, scc, num_slots); + UL_tti_req_ahead_initialization(gNB, scc, num_slots, CC_idP); nfapi_nr_dl_tti_request_t *DL_req = &gNB->DL_req[0]; nfapi_nr_dl_tti_pdcch_pdu_rel15_t **pdcch = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t **)gNB->pdcch_pdu_idx[CC_idP]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index efc83c034f..f0dc29b2db 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2995,18 +2995,19 @@ void schedule_nr_bwp_switch(module_id_t module_id, } } -void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n) { +void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n, int CCid) { - gNB->UL_tti_req_ahead[0] = calloc(n, sizeof(nfapi_nr_ul_tti_request_t)); - AssertFatal(gNB->UL_tti_req_ahead[0], + if(gNB->UL_tti_req_ahead[CCid]) return; + + gNB->UL_tti_req_ahead[CCid] = calloc(n, sizeof(nfapi_nr_ul_tti_request_t)); + AssertFatal(gNB->UL_tti_req_ahead[CCid], "could not allocate memory for RC.nrmac[]->UL_tti_req_ahead[]\n"); /* fill in slot/frame numbers: slot is fixed, frame will be updated by scheduler * consider that scheduler runs sl_ahead: the first sl_ahead slots are * already "in the past" and thus we put frame 1 instead of 0! */ for (int i = 0; i < n; ++i) { - nfapi_nr_ul_tti_request_t *req = &gNB->UL_tti_req_ahead[0][i]; + nfapi_nr_ul_tti_request_t *req = &gNB->UL_tti_req_ahead[CCid][i]; req->SFN = i < (gNB->if_inst->sl_ahead-1); req->Slot = i; } - gNB->init_UL_tti_req_ahead = true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 9dbd745c19..6ef11a433d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -522,7 +522,7 @@ int get_mcs_from_bler(const NR_bler_options_t *bler_options, int max_mcs, frame_t frame); -void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n); +void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCommon_t *scc, int n, int CCid); void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 52ba4bf16a..03a982ab7b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -850,7 +850,6 @@ typedef struct gNB_MAC_INST_s { uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; - bool init_UL_tti_req_ahead; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ From 2802418c34b703334ae6eafa453c4c53c211e420 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 21 Jun 2022 16:43:54 +0200 Subject: [PATCH 79/84] remove debug printf --- openair2/F1AP/f1ap_du_task.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 5212e325b3..f8cf216220 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -126,7 +126,6 @@ void *F1AP_DU_task(void *arg) { LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n"); f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg); createF1inst(false, myInstance, msgSetup); -printf("XXXXXXXXXXXXXXX old 172.21.6.9 new %s\n", msgSetup->CU_f1_ip_address.ipv4_address); getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu(msgSetup->CU_f1_ip_address.ipv4_address, //"172.21.6.9", //"172.21.10.9",//"172.21.9.5", //msgSetup->CU_f1_ip_address.ipv4_address, //"192.168.18.91" msgSetup->CUport, msgSetup->DU_f1_ip_address.ipv4_address, From f6fe86c653a350424a84ba8beb2f3990573f5c0d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 21 Jun 2022 19:24:04 +0200 Subject: [PATCH 80/84] Fix macros to avoid warnings --- openair3/UTILS/conversions.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openair3/UTILS/conversions.h b/openair3/UTILS/conversions.h index 00b650a302..a753b8c60d 100644 --- a/openair3/UTILS/conversions.h +++ b/openair3/UTILS/conversions.h @@ -70,8 +70,8 @@ /* Convert an integer on 16 bits to the given bUFFER */ #define INT16_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x) >> 8; \ - (buf)[1] = (x); \ + (buf)[0] = (x >> 8) & 0xff; \ + (buf)[1] = (x) & 0xff; \ } while(0) /* Convert an array of char containing vALUE to x */ @@ -84,9 +84,9 @@ do { \ /* Convert an integer on 24 bits to the given bUFFER */ #define INT24_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x) >> 16; \ - (buf)[1] = (x) >> 8; \ - (buf)[2] = (x); \ + (buf)[0] = (x >> 16) & 0xff;\ + (buf)[1] = (x >> 8) & 0xff; \ + (buf)[2] = (x) & 0xff; \ } while(0) /* Convert an array of char containing vALUE to x */ @@ -101,10 +101,10 @@ do { \ /* Convert an integer on 32 bits to the given bUFFER */ #define INT32_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x) >> 24; \ - (buf)[1] = (x) >> 16; \ - (buf)[2] = (x) >> 8; \ - (buf)[3] = (x); \ + (buf)[0] = (x >> 24) & 0xff;\ + (buf)[1] = (x >> 16) & 0xff;\ + (buf)[2] = (x >> 8) & 0xff; \ + (buf)[3] = (x) & 0xff; \ } while(0) /* Convert an array of char containing vALUE to x */ From 4505e780c53f6fabd0ba629377e0931690601bfd Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 23 Jun 2022 11:44:01 +0200 Subject: [PATCH 81/84] nr rlc: minor: update tests Behavior for ack/nack generation has changed not too long ago but the tests were not checked and updated. --- openair2/LAYER2/nr_rlc/tests/test14.txt.gz | Bin 799 -> 787 bytes openair2/LAYER2/nr_rlc/tests/test15.txt.gz | Bin 554 -> 547 bytes openair2/LAYER2/nr_rlc/tests/test8.txt.gz | Bin 319 -> 319 bytes openair2/LAYER2/nr_rlc/tests/test9.txt.gz | Bin 316 -> 316 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz index 45e54651eb317c3b7695cfcab7428fe43172227b..53cea67c98d98e91baa4bfcd40518b523ef5a21f 100644 GIT binary patch delta 703 zcmV;w0zmzr29pMVABzYGiZ!%i0t0kqb96B@E_8Tw0Ns{5ZyZMugmeFjFSHY3X1eFa zP_W?4iKxghhz#awlMcouFr?x~jT%Z{NMYy5_#3W3{6imf5%(8J{ zCe~mr)?o#!SdR_Zh)vjxE!c`}*p408i8DBhb2z~%&f@|u;u0?73a;WBuHy!7A_lR) zAL9Qw{uryW8Fzp7?Gt#}fp2Dy-&}qd?nniDsDd~|5Jfx^kccECBL%5QLpm~$i5k?R z4i!{Uj|Mb)U-BeLUQM8Y|xa{NYJ~YY;$=4CD?C6qMizfe;CakO_rQ360PRgD{DP zXo-#}L?wD+AVy*$W?~^$Vk36qAWo7YS&}0ONlBhS6iAVjNSRbfmDEU`G)R+d$d>HL zLRPXrpnhqfZs#1UyCtDE+x0%FmiOJh3t{v3wBU zrIa3~R7E3`^$v`!neNjG#$cXXjE-O~d-(i1(?3%$}Cy)UyspA5sW495_LGCU(N zA|o*}qcAF?F*;)~Cetu2(=mmqbxh9;%*ag4eB8h}9rUu>cubA_rP#Q9>^rMGGltIP%7@oQMbOLxeI^oI(c~4>T-$>yXHeMwGrzhwNu!nOWPOAr+E%mz|4S$t2>uqae ly`I~Lhku?Z82!zOdi%n9_riL4VZA9hABzYGOnK#D0t0kqb96B@E_8Tw0Ns{LYhyM4NCCm^MOEKZ=bSpax9>mP-mu=3)#kg~ z{rThj8|)3M(LUX+`va@j9?Uh<1qmfF$t3~1yeB%vosFO z#2T!{I;>z7>#+eFu?d^81zWKV+pz;XaRz5`4ktLpd0fCnT*75s!Bt$tb=<&B#31&! zL;SywKgOzT#@(NN`vhKg;G5awH34cl-io5)8o-96^ro zpHsnJ_7p$=^5cGtJ|6BrjTIk$`uL>4H3%R_26Bf63QF*VK!}7y$b>?ughuFuL6}5C zv_wY~q7pqZ5F;@WGqDgWu@O6Q5GToyEXk3Cq$E#33ZzI%q)aNLN@}D|8l*`!WJ`8r zAuHJ*P`?aNw{wow-I7q7?RuY7%kyqOg|PYi@nn`c|2ZFBaKeJ}6k@yIlf40Af8Xj@ zeVt?Vykq4$XglrL%ZKjYsf~2-nKT@>$!b+`23{)=4~1{gPyRnr{*A_~B;fSMT>eEYZ;s0ssI@?OqfB diff --git a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz index ddb895d56f0fe88f0ceffb9a100359413292f2b7..61fa01663479944ed13d1c30ee2c3adbe5a70cb1 100644 GIT binary patch literal 547 zcmV+;0^I!{iwFpnHMC*^19W9`bTKt9ba-?C&6Q1WQ!x-l_xy^pgbnhH$6r|@Dt2tz zt`MsHp8Zgz3ZbMaf?rRPCa8gss7RDbmgR-VI(K}peQ|bvF=KIC=eI8|HtToq-^`F1 z^FH2PE!vWo*A4e-wdwkMC%73Oa1JLp#d)0J0xsebF5?QW;s)G^TNQTPgg8VHMLc3i zKq8Wmj1;6I12Q5F>BxjSR8U1dYG^5R0;rw92Yulec&zP0%t?>~Q9y*#lC_xS9zdfBS~3-gB4>h*~& zyvG-hsP8+zd-acV{^i-`@YZjx@A{ncx0k!nKKIOS$q%%}?_T`%c({FipNHBg4+`pb zu?pyYKiBgr=(_Jl`B!1waLS)<8<{$x6k^E-Jzeb`}o^ktTj5m l)&+~@IQGS2THf4z+qIy#*M|z^u?2dx;0IK+b^){r001`Y7gzuQ literal 554 zcmV+_0@eK=iwFo?BT%gc&;HC?*=-Ux2N2b{wRPH`S*xPXhegv+>s>u^18z)gh>HzE!ZL=le| z5|D@_BqIgskRBP3iZo=W>c_jtnx ze8eYw#ut2t@9_h^;v0U%9444z9y2Up5ldLc3f5sgHeeNN*f{kk2tf&+V1z)3gha@M zLg)xRVIWk(1ZE^Uq7aqn4-(LQ0?~+p7>S9PiG|n^d*VQ>#6}!RjwB={d6JO=DUuQ? zlM1OL^`wDRNsTm;9a+dq_GBXmawI2mCKqx??#TnWk{fxXIEqk|;weT6zY_S=KDT9e z-7db=^%lKt&`*`_=XyFL?cvjV@kyTXb$9U1=6k&V{Bid3#4g;!XUEygmi=FtHymfL zPi)~meDMJLw!?SJ{&CJfKiM>|?dtNTEjfLAz6;&{nH)eRcJ1CuOUz_X^}+rFTP29vb2E|M*M~ sWUv0;muI7`KBVol{*!mmkK|+cZ5A^}_s6#07RbSZA0L&&0<;ML09iH+!vFvP diff --git a/openair2/LAYER2/nr_rlc/tests/test8.txt.gz b/openair2/LAYER2/nr_rlc/tests/test8.txt.gz index c20d43c63b331c2de77e0484922c1b0c1957eb7c..461ae1aebad7294daa7445179da725cbe6e722d0 100644 GIT binary patch literal 319 zcmV-F0l@wriwFpCHMC*^19W9`bT}?_cys{Gl1od&P!NUp{T1I*H!?GMG|5sd?%cFp ziIhBUq)(OlYzrDN8(2T~Fn?+l7 zTr4Z(a$B@~b3~GHj|ifOApsI15fUR~BtcRnM+&4wwv7&{Q9%_oG(bZ%LSuA{CTNQ0 zXn~e!g*vpx1XIkg01L4Qi?K15U@4Yk1y*7e=CGPT2=w6xz@vL|O}=)E=c?PgH}mdO z*#Vr+Fi^51N=2{ap-B0K+>n@Uyu5b_T zO$|XpIg(j@uFSkyuT;6!a^o7NH}n36|N9B|){pH)zwPBSRnI8A_o*r^>CC8`m(snfHJAzklIA`mw#}x4nF}>KTQXyru2R(zR{ftyZsn R1+Kapy#sK9u$l1#007C*o1g#y diff --git a/openair2/LAYER2/nr_rlc/tests/test9.txt.gz b/openair2/LAYER2/nr_rlc/tests/test9.txt.gz index 27590b7d71c435e04cd19603d90cc0c9c0798597..938fcd6ddcb9a2bcf4bbd2206725a7c35e2a2b79 100644 GIT binary patch delta 298 zcmV+_0oDGz0=xnUABzYGfi<*Zkq8}sNt-Oi;?7Oml}O3YL<&VDX)5~kc8Y;UYo+2s zn8hsS&iT$aGoQ}p8SN%-Hlz7|e|vYGp&5-Yx68KbxL8%l*WP=`inj3($9ouDb2qXk-`73$F%6HGC~92Q}JF_vIs zY=Wg&julvmRhY+WoZ$4~lfa{Y@=d<+%jc^5NN*O>r?MB2Uuz6Vc7jwKkb?Tz_5+eT zO42lt`~fL6c5Z2l>38?L{=vf<98Ztuk%NJxm+vbG@rG8BoG7sVs{%vdK&t$Dwe=0N wn??Vj|NDRLqyO+W(U(?(qwta$x3pbZ`nIjR_4>81z*kqJcO1rN|Na9207W#H^#A|> delta 298 zcmV+_0oDGz0=xnUABzYG2sNf*kq8}sX`3v?;?7Oml}O3YL;^)5X)5~kc8Y;UYo+2s zn8hsS&iT$avzW~nDeWd}HlxLUe|vYGqA86pwyU=6xTs6ya(AeH^Td*Jj|ifOAr6U< z7#SlIWQrt6hU7?r>;^qjp@J%Es6!((M#ty`ouUbvp*dQhCF;=%6HGC~92Q}JF*e2~ z*c3~!49l?sD>08%IKk<|CxJ)*A3zt$L#>;x%4AO-ca?FS@x zl%z=@`2$jD?A+3pv+wSA{ey=!IG!BOBL@T4%l8$8ctfj5P83-ERe>RJAeDYyZ+*l3 wX4!w}|Nfu*=s&zo^rh9{D7<7DEp1m6zHO^+y?*U0@a5I$9m#xc_x=L_0Q8xU(f|Me From 304c92c6391393a599037888be22cf5f8da415f9 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 23 Jun 2022 13:51:36 +0200 Subject: [PATCH 82/84] Fixes in conversions.h --- openair3/UTILS/conversions.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair3/UTILS/conversions.h b/openair3/UTILS/conversions.h index a753b8c60d..0361c34f33 100644 --- a/openair3/UTILS/conversions.h +++ b/openair3/UTILS/conversions.h @@ -70,7 +70,7 @@ /* Convert an integer on 16 bits to the given bUFFER */ #define INT16_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x >> 8) & 0xff; \ + (buf)[0] = ((x) >> 8) & 0xff; \ (buf)[1] = (x) & 0xff; \ } while(0) @@ -84,8 +84,8 @@ do { \ /* Convert an integer on 24 bits to the given bUFFER */ #define INT24_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x >> 16) & 0xff;\ - (buf)[1] = (x >> 8) & 0xff; \ + (buf)[0] = ((x) >> 16) & 0xff;\ + (buf)[1] = ((x) >> 8) & 0xff; \ (buf)[2] = (x) & 0xff; \ } while(0) @@ -101,9 +101,9 @@ do { \ /* Convert an integer on 32 bits to the given bUFFER */ #define INT32_TO_BUFFER(x, buf) \ do { \ - (buf)[0] = (x >> 24) & 0xff;\ - (buf)[1] = (x >> 16) & 0xff;\ - (buf)[2] = (x >> 8) & 0xff; \ + (buf)[0] = ((x) >> 24) & 0xff;\ + (buf)[1] = ((x) >> 16) & 0xff;\ + (buf)[2] = ((x) >> 8) & 0xff; \ (buf)[3] = (x) & 0xff; \ } while(0) From 0e04fba03d8b1d3e28e70d57933809a6f570709c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 23 Jun 2022 14:49:16 +0200 Subject: [PATCH 83/84] Fix build warnings --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 ++ openair1/SIMULATION/NR_PHY/prachsim.c | 2 ++ openair1/SIMULATION/NR_PHY/ulsim.c | 2 ++ openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c | 2 +- openair2/RRC/NR/rrc_gNB.c | 1 - 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index fec711bc1b..78b253ca2a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -243,6 +243,8 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, void processSlotTX(void *arg) {} +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + //nFAPI P7 dummy functions to avoid linking errors int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 91a8265ff1..33717c944d 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -227,6 +227,8 @@ nrUE_params_t *get_nrUE_params(void) { return &nrUE_params; } +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + void processSlotTX(void *arg) {} int main(int argc, char **argv){ diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 22efa35ef9..ffb168fd68 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -225,6 +225,8 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + //nFAPI P7 dummy functions int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c index 41d27bda80..97938c6b02 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.c @@ -55,10 +55,10 @@ void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int slot, return; } +extern nr_bler_struct nr_bler_data[NR_NUM_MCS]; float get_bler_val(uint8_t mcs, int sinr) { // 4th col = dropped packets, 5th col = total packets - nr_bler_struct nr_bler_data[NR_NUM_MCS]; float bler_val = 0.0; CHECK_INDEX(nr_bler_data, mcs); LOG_D(NR_MAC, "sinr %d min %d max %d\n", sinr, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 98a373086e..20b79362a0 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1426,7 +1426,6 @@ rrc_gNB_process_RRCReconfigurationComplete( NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; NR_DRB_Identity_t *drb_id_p = NULL; // uint8_t nr_DRB2LCHAN[8]; - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; ue_context_pP->ue_context.ue_reestablishment_timer = 0; From a9faf533b4c0d264e3ed22c24a010bce857e2d0d Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 24 Jun 2022 14:29:35 +0100 Subject: [PATCH 84/84] Fix SA with COTS UE in monolithic mode after merge --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 5 ----- openair2/RRC/NR/L2_nr_interface.c | 8 -------- openair2/RRC/NR/nr_rrc_proto.h | 6 ------ openair2/RRC/NR/rrc_gNB.c | 10 +++++----- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index b87edc9926..6daa68afed 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1530,11 +1530,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { - if (nr_mac_rrc_check_RRCSetup(module_idP, ra->rnti) <= 0){ - ra->Msg4_frame++; - return; - } - uint8_t time_domain_assignment = 0; uint8_t mcsIndex = 0; diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 7d315bf766..161d1cd847 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -306,14 +306,6 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, return 0; } -int8_t nr_mac_rrc_check_RRCSetup(const module_id_t Mod_idP, - const rnti_t rnti) { - struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti); - char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size; - return payload_size; - -} - int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, const int CC_id, const frame_t frameP, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 40de8b8049..d569b91aa8 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -163,12 +163,6 @@ nr_rrc_data_req( const pdcp_transmission_mode_t modeP ); -int8_t nr_mac_rrc_check_RRCSetup( - const module_id_t Mod_idP, - const rnti_t rnti - -); - int nr_rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 20b79362a0..3d95081336 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -600,8 +600,7 @@ rrc_gNB_process_RRCSetupComplete( void rrc_gNB_generate_defaultRRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP, - NR_CellGroupConfig_t *cellGroupConfig + rrc_gNB_ue_context_t *ue_context_pP ) //----------------------------------------------------------------------------- { @@ -716,6 +715,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( } gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; memset(buffer, 0, sizeof(buffer)); size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, @@ -730,7 +730,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( &rrc->carrier, &rrc->configuration, NULL, - cellGroupConfig); + ue_p->masterCellGroup); free(ue_context_pP->ue_context.nas_pdu.buffer); @@ -2778,7 +2778,7 @@ rrc_gNB_decode_dcch( if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p, NULL); } else { - rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p, NULL); + rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); } } else{ @@ -3711,7 +3711,7 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const ch if (ue_context_p->ue_context.established_pdu_sessions_flag == 1) { rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p, cellGroupConfig); } else { - rrc_gNB_generate_defaultRRCReconfiguration(&ctxt, ue_context_p, NULL); + rrc_gNB_generate_defaultRRCReconfiguration(&ctxt, ue_context_p); } free(cellGroupConfig->rlc_BearerToAddModList);