From 021d7abf8a205f5aae1783f19c8c1dea5ebc042e Mon Sep 17 00:00:00 2001 From: Bing-Kai Hong Date: Fri, 7 Sep 2018 19:04:45 +0200 Subject: [PATCH] Create the F1 pingpong procedure with SCTP --- cmake_targets/CMakeLists.txt | 1 + common/utils/LOG/log.c | 4 +- common/utils/LOG/log.h | 2 + common/utils/T/T_messages.txt | 30 ++++++++++++ openair2/ENB_APP/enb_app.c | 4 +- openair2/F1AP/CU_F1AP.c | 55 ++++++++++++++++------ openair2/F1AP/DU_F1AP.c | 24 ++++++---- openair2/F1AP/f1ap_handlers.c | 2 +- openair2/F1AP/f1ap_itti_messaging.c | 73 +++++++++++++++++++++++++++++ openair2/F1AP/f1ap_itti_messaging.h | 35 ++++++++++++++ targets/RT/USER/lte-softmodem.c | 6 +++ targets/RT/USER/lte-softmodem.h | 1 + 12 files changed, 209 insertions(+), 28 deletions(-) create mode 100644 openair2/F1AP/f1ap_itti_messaging.c create mode 100644 openair2/F1AP/f1ap_itti_messaging.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index fc646020b7..6beb215838 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -543,6 +543,7 @@ add_library(F1AP #${F1AP_DIR}/test.c ${F1AP_DIR}/DU_F1AP.c ${F1AP_DIR}/CU_F1AP.c + ${F1AP_DIR}/f1ap_itti_messaging.c ${F1AP_DIR}/f1ap_encoder.c ${F1AP_DIR}/f1ap_decoder.c ${F1AP_DIR}/f1ap_handlers.c diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 02ee849202..20442a02a4 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -418,7 +418,9 @@ int logInit (void) register_log_component("S1AP","",S1AP); - + register_log_component("F1AP","",F1AP); + register_log_component("CU_F1AP","",CU_F1AP); + register_log_component("DU_F1AP","",DU_F1AP); register_log_component("SCTP","",SCTP); register_log_component("RRH","",RRH); diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 7354c32c7d..9e1feab22e 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -174,6 +174,8 @@ typedef enum { SPGW, S1AP, F1AP, + DU_F1AP, + CU_F1AP, SCTP, HW, OSA, diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 904fcb7355..8887bb4110 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -883,6 +883,36 @@ ID = LEGACY_F1AP_ERROR GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_ERROR:LEGACY FORMAT = string,log +ID = LEGACY_CU_F1AP_DEBUG + DESC = CU_F1AP DEBUG LEVEL + GROUP = ALL:LEGACY_CU_F1AP:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log + +ID = LEGACY_CU_F1AP_INFO + DESC = CU_F1AP INFO LEVEL + GROUP = ALL:LEGACY_CU_F1AP:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log + +ID = LEGACY_CU_F1AP_ERROR + DESC = CU_F1AP ERROR LEVEL + GROUP = ALL:LEGACY_CU_F1AP:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log + +ID = LEGACY_DU_F1AP_DEBUG + DESC = DU_F1AP DEBUG LEVEL + GROUP = ALL:LEGACY_DU_F1AP:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log + +ID = LEGACY_DU_F1AP_INFO + DESC = DU_F1AP INFO LEVEL + GROUP = ALL:LEGACY_DU_F1AP:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log + +ID = LEGACY_DU_F1AP_ERROR + DESC = DU_F1AP ERROR LEVEL + GROUP = ALL:LEGACY_DU_F1AP:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log + ################# #### UE LOGS #### ################# diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index de1e655d32..c120e79496 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -76,14 +76,12 @@ static void create_remaining_tasks(module_id_t enb_id) case ngran_eNB_CU: case ngran_ng_eNB_CU: case ngran_gNB_CU: - rc = itti_create_task(TASK_CU_F1, F1AP_CU_task, NULL); + rc = itti_create_task(TASK_CU_F1, F1AP_CU_task, enb_id); AssertFatal(rc >= 0, "Create task for CU F1AP failed\n"); /* fall through */ case ngran_eNB: case ngran_ng_eNB: case ngran_gNB: - rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL); - AssertFatal(rc >= 0, "Create task for SCTP failed\n"); rc = itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for S1AP failed\n"); if (!emulate_rf){ diff --git a/openair2/F1AP/CU_F1AP.c b/openair2/F1AP/CU_F1AP.c index 2c766074bd..4233eed3f5 100644 --- a/openair2/F1AP/CU_F1AP.c +++ b/openair2/F1AP/CU_F1AP.c @@ -40,6 +40,8 @@ #include "platform_types.h" #include "common/utils/LOG/log.h" #include "intertask_interface.h" +#include "f1ap_itti_messaging.h" +#include #include "T.h" @@ -100,6 +102,7 @@ void CU_send_sctp_init_req(instance_t enb_id) { // 2. use RC.rrc[enb_id] to fill the sctp_init_t with the ip, port // 3. creat an itti message to init + LOG_I(CU_F1AP, "F1AP_CU_SCTP_REQ\n"); MessageDef *message_p = NULL; message_p = itti_alloc_new_message (TASK_CU_F1, SCTP_INIT_MSG); @@ -108,7 +111,7 @@ void CU_send_sctp_init_req(instance_t enb_id) { message_p->ittiMsg.sctp_init.ipv4 = 1; message_p->ittiMsg.sctp_init.ipv6 = 0; message_p->ittiMsg.sctp_init.nb_ipv4_addr = 1; - message_p->ittiMsg.sctp_init.ipv4_address[0] = RC.rrc[enb_id]->eth_params_s.my_addr; + message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(RC.rrc[enb_id]->eth_params_s.my_addr); /* * SR WARNING: ipv6 multi-homing fails sometimes for localhost. * * * * Disable it for now. @@ -116,38 +119,54 @@ void CU_send_sctp_init_req(instance_t enb_id) { message_p->ittiMsg.sctp_init.nb_ipv6_addr = 0; message_p->ittiMsg.sctp_init.ipv6_address[0] = "0:0:0:0:0:0:0:1"; + LOG_I(CU_F1AP,"CU.my_addr = %s \n", RC.rrc[enb_id]->eth_params_s.my_addr); + LOG_I(CU_F1AP,"CU.enb_id = %d \n", enb_id); itti_send_msg_to_task(TASK_SCTP, enb_id, message_p); } void *F1AP_CU_task(void *arg) { - printf("Start F1AP CU task!\n"); - //sctp_cu_init(); MessageDef *received_msg = NULL; int result; - //F1AP_DEBUG("Starting F1AP at DU\n"); + LOG_I(CU_F1AP,"Starting F1AP at CU\n"); //f1ap_eNB_prepare_internal_data(); itti_mark_task_ready(TASK_CU_F1); + CU_send_sctp_init_req(arg); + while (1) { itti_receive_msg(TASK_CU_F1, &received_msg); switch (ITTI_MSG_ID(received_msg)) { - case F1AP_CU_SCTP_REQ: - CU_send_sctp_init_req(ITTI_MESSAGE_GET_INSTANCE(received_msg)); + // case F1AP_CU_SCTP_REQ: + // LOG_I(CU_F1AP, "F1AP_CU_SCTP_REQ\n"); + + // break; + + case SCTP_NEW_ASSOCIATION_IND: + LOG_I(CU_F1AP, "SCTP_NEW_ASSOCIATION_IND\n"); + CU_handle_sctp_association_ind(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &received_msg->ittiMsg.sctp_new_association_ind); break; - case SCTP_DATA_IND: + case SCTP_NEW_ASSOCIATION_RESP: + LOG_I(CU_F1AP, "SCTP_NEW_ASSOCIATION_RESP\n"); + CU_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &received_msg->ittiMsg.sctp_new_association_resp); + break; + + case SCTP_DATA_IND: + LOG_I(CU_F1AP, "SCTP_DATA_IND\n"); CU_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind); break; default: - // F1AP_ERROR("CU Received unhandled message: %d:%s\n", - // ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); + LOG_E(CU_F1AP, "CU Received unhandled message: %d:%s\n", + ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); break; } // switch result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); @@ -160,6 +179,14 @@ void *F1AP_CU_task(void *arg) { } +void CU_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind) { + CU_send_F1_SETUP_RESPONSE(instance, sctp_new_association_ind); +} + +void CU_handle_sctp_association_resp(instance_t instance, sctp_new_association_ind_t *sctp_new_association_resp) { + //CU_send_F1_SETUP_RESPONSE(instance, sctp_new_association_resp); +} + // ============================================================================== void CU_handle_F1_SETUP_REQUEST(F1AP_F1SetupRequest_t *message_p) { F1AP_F1AP_PDU_t pdu; @@ -184,7 +211,7 @@ void CU_handle_F1_SETUP_REQUEST(F1AP_F1SetupRequest_t *message_p) { } -void CU_send_F1_SETUP_RESPONSE(void) { +void CU_send_F1_SETUP_RESPONSE(instance_t instance, sctp_new_association_ind_t *f1ap_setup_ind) { //void CU_send_F1_SETUP_RESPONSE(F1AP_F1SetupResponse_t *F1SetupResponse) { //AssertFatal(1==0,"Not implemented yet\n"); @@ -315,11 +342,11 @@ void CU_send_F1_SETUP_RESPONSE(void) { } // printf("\n"); - + cu_f1ap_itti_send_sctp_data_req(instance, f1ap_setup_ind->assoc_id, buffer, len, 0); /* decode */ - if (f1ap_decode_pdu(&pdu, buffer, len) > 0) { - printf("Failed to decode F1 setup request\n"); - } + // if (f1ap_decode_pdu(&pdu, buffer, len) > 0) { + // printf("Failed to decode F1 setup request\n"); + // } //printf("F1 setup response present = %d\n", out->value.present); //f1ap_send_sctp_data_req(instance_p->instance, f1ap_mme_data_p->assoc_id, buffer, len, 0); diff --git a/openair2/F1AP/DU_F1AP.c b/openair2/F1AP/DU_F1AP.c index c7acd198c6..46c5eab800 100644 --- a/openair2/F1AP/DU_F1AP.c +++ b/openair2/F1AP/DU_F1AP.c @@ -40,6 +40,7 @@ #include "common/utils/LOG/log.h" #include "sctp_du.h" #include "intertask_interface.h" +#include "f1ap_itti_messaging.h" #include "T.h" @@ -102,14 +103,13 @@ void DU_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind) } void *F1AP_DU_task(void *arg) { - printf("Start F1AP DU task!\n"); //sctp_cu_init(); MessageDef *received_msg = NULL; int result; - //F1AP_DEBUG("Starting F1AP at DU\n"); + LOG_I(DU_F1AP, "Starting F1AP at DU\n"); //f1ap_eNB_prepare_internal_data(); @@ -118,7 +118,7 @@ void *F1AP_DU_task(void *arg) { // SCTP while (1) { itti_receive_msg(TASK_DU_F1, &received_msg); - + switch (ITTI_MSG_ID(received_msg)) { // case TERMINATE_MESSAGE: @@ -130,6 +130,7 @@ void *F1AP_DU_task(void *arg) { // 1. save the itti msg so that you can use it to sen f1ap_setup_req, fill the f1ap_setup_req message, // 2. store the message in f1ap context, that is also stored in RC // 2. send a sctp_association req + LOG_I(DU_F1AP, "F1AP_SETUP_REQ\n"); DU_send_sctp_association_req(ITTI_MESSAGE_GET_INSTANCE(received_msg), &F1AP_SETUP_REQ(received_msg)); break; @@ -137,18 +138,20 @@ void *F1AP_DU_task(void *arg) { case SCTP_NEW_ASSOCIATION_RESP: // 1. store the respon // 2. send the f1setup_req + LOG_I(DU_F1AP, "SCTP_NEW_ASSOCIATION_RESP\n"); DU_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), &received_msg->ittiMsg.sctp_new_association_resp); break; case SCTP_DATA_IND: // ex: any F1 incoming message for DU ends here + LOG_I(DU_F1AP, "SCTP_DATA_IND\n"); DU_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind); break; default: - // F1AP_ERROR("DU Received unhandled message: %d:%s\n", - // ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); + LOG_E(DU_F1AP, "DU Received unhandled message: %d:%s\n", + ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); break; } // switch result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); @@ -172,7 +175,7 @@ static void du_f1ap_register(du_f1ap_instance_t *instance_p, MessageDef *message_p = NULL; sctp_new_association_req_t *sctp_new_association_req_p = NULL; - message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ); + message_p = itti_alloc_new_message(TASK_DU_F1, SCTP_NEW_ASSOCIATION_REQ); sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req; sctp_new_association_req_p->ulp_cnx_id = instance_p->instance; @@ -244,8 +247,11 @@ void DU_handle_sctp_association_resp(instance_t instance, sctp_new_association_r // SETUP REQUEST -void DU_send_F1_SETUP_REQUEST(module_id_t enb_mod_idP, module_id_t du_mod_idP, f1ap_setup_req_t *msg_p) { -//void DU_send_F1_SETUP_REQUEST(F1SetupRequest_t *F1SetupRequest) { +//void DU_send_F1_SETUP_REQUEST(instance_t instance, f1ap_setup_req_t *f1ap_setup_req) { +void DU_send_F1_SETUP_REQUEST(instance_t instance, sctp_new_association_resp_t *f1ap_setup_req) { + module_id_t enb_mod_idP; + module_id_t du_mod_idP; + F1AP_F1AP_PDU_t pdu; F1AP_F1SetupRequest_t *out; F1AP_F1SetupRequestIEs_t *ie; @@ -478,7 +484,7 @@ void DU_send_F1_SETUP_REQUEST(module_id_t enb_mod_idP, module_id_t du_mod_idP, f printf("Failed to encode F1 setup request\n"); } - f1ap_du_send_message(buffer, len); + du_f1ap_itti_send_sctp_data_req(instance, f1ap_setup_req->assoc_id, buffer, len, 0); // printf("\n"); /* decode */ diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index a436696fe0..4501975d7a 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -147,7 +147,7 @@ int f1ap_handle_f1_setup_request(uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - printf("OOOOOOOOOOOOOOOOOOOOOOOOOOO\n"); + printf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"); return 0; } diff --git a/openair2/F1AP/f1ap_itti_messaging.c b/openair2/F1AP/f1ap_itti_messaging.c new file mode 100644 index 0000000000..e51b5ad99b --- /dev/null +++ b/openair2/F1AP/f1ap_itti_messaging.c @@ -0,0 +1,73 @@ +/* + * 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 "intertask_interface.h" + +#include "f1ap_itti_messaging.h" + +void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream) +{ + MessageDef *message_p; + sctp_data_req_t *sctp_data_req; + + message_p = itti_alloc_new_message(TASK_CU_F1, SCTP_DATA_REQ); + + sctp_data_req = &message_p->ittiMsg.sctp_data_req; + + sctp_data_req->assoc_id = assoc_id; + sctp_data_req->buffer = buffer; + sctp_data_req->buffer_length = buffer_length; + sctp_data_req->stream = stream; + + itti_send_msg_to_task(TASK_SCTP, instance, message_p); +} + +void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream) +{ + MessageDef *message_p; + sctp_data_req_t *sctp_data_req; + + message_p = itti_alloc_new_message(TASK_DU_F1, SCTP_DATA_REQ); + + sctp_data_req = &message_p->ittiMsg.sctp_data_req; + + sctp_data_req->assoc_id = assoc_id; + sctp_data_req->buffer = buffer; + sctp_data_req->buffer_length = buffer_length; + sctp_data_req->stream = stream; + + itti_send_msg_to_task(TASK_SCTP, instance, message_p); +} + +void f1ap_itti_send_sctp_close_association(instance_t instance, int32_t assoc_id) +{ + MessageDef *message_p = NULL; + sctp_close_association_t *sctp_close_association_p = NULL; + + message_p = itti_alloc_new_message(TASK_S1AP, SCTP_CLOSE_ASSOCIATION); + sctp_close_association_p = &message_p->ittiMsg.sctp_close_association; + sctp_close_association_p->assoc_id = assoc_id; + + itti_send_msg_to_task(TASK_SCTP, instance, message_p); +} + diff --git a/openair2/F1AP/f1ap_itti_messaging.h b/openair2/F1AP/f1ap_itti_messaging.h new file mode 100644 index 0000000000..66c59a72e7 --- /dev/null +++ b/openair2/F1AP/f1ap_itti_messaging.h @@ -0,0 +1,35 @@ +/* + * 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 F1AP_ITTI_MESSAGING_H_ +#define F1AP_ITTI_MESSAGING_H_ + +void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream); + +void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream); + +void f1ap_eNB_itti_send_sctp_close_association(instance_t instance, + int32_t assoc_id); + + +#endif /* F1AP_ITTI_MESSAGING_H_ */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index d2022540c1..da114515e8 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1063,6 +1063,7 @@ int main( int argc, char **argv ) int have_rrc=0; if (RC.nb_inst > 0) { + itti_wait_ready(1); LOG_I(ENB_APP, "Creating ENB_APP eNB Task\n"); if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { LOG_E(ENB_APP, "Create task for eNB APP failed\n"); @@ -1074,6 +1075,11 @@ int main( int argc, char **argv ) return -1; } have_rrc=1; + if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) { + LOG_E(SCTP, "Create task for SCTP failed\n"); + return -1; + } + itti_wait_ready(0); } else { printf("No ITTI, Initializing L1\n"); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 7f0288ea91..22090c0625 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -290,5 +290,6 @@ extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t abstraction_flag); extern void *eNB_app_task(void* args); +extern void *sctp_eNB_task(void *args); #endif