Commit b3f46402 authored by Xue Song's avatar Xue Song

add new gtpu for 5GSA

parent 89c743bb
......@@ -183,7 +183,10 @@ typedef struct {
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;
......
......@@ -889,14 +889,17 @@ int RCconfig_nr_gtpu(void ) {
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
AssertFatal((message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_GNB_NG_REQ))!=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);
}
strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address);
sprintf(GTPV1U_ENB_S1_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)
} else
LOG_E(GTPU,"invalid address for NGU\n");
......
......@@ -91,6 +91,7 @@
#include "BIT_STRING.h"
#include "assertions.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
//#define XER_PRINT
......@@ -2011,7 +2012,7 @@ rrc_gNB_decode_dcch(
}
}
itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p);
itti_send_msg_to_task(TASK_VARIABLE, ctxt_pP->instance, msg_delete_tunnels_p);
//NGAP_PDUSESSION_RELEASE_RESPONSE
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(ctxt_pP, ue_context_p, xid);
} else {
......
......@@ -58,6 +58,7 @@
#include "NR_UERadioAccessCapabilityInformation.h"
#include "NR_UE-CapabilityRAT-ContainerList.h"
#include "f1ap_messages_types.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
extern RAN_CONTEXT_t RC;
......@@ -1407,7 +1408,7 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
}
}
itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
itti_send_msg_to_task(TASK_VARIABLE, instance, msg_delete_tunnels_p);
//NGAP_PDUSESSION_RELEASE_RESPONSE
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(&ctxt, ue_context_p, xid);
LOG_I(NR_RRC, "Send PDU Session Release Response \n");
......
......@@ -85,6 +85,8 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "nr_nas_msg_sim.h"
#endif
#include <openair3/ocp-gtpu/gtp_itf.h>
pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
......@@ -301,10 +303,17 @@ int create_gNB_tasks(uint32_t gnb_nb) {
}
}
#if defined(NEW_GTPU)
if (itti_create_task (TASK_GTPV1_U, &gtpv1u_gNB_task, NULL) < 0) {
LOG_E(GTPU, "Create task for GTPV1U failed\n");
return -1;
}
#else
if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) {
LOG_E(GTPU, "Create task for GTPV1U failed\n");
return -1;
}
#endif
}
}
......
......@@ -707,6 +707,76 @@ void gtpv1uReceiver(int h) {
}
}
int ocp_gtpv1u_create_ngu_tunnel(const instance_t instance,
const gtpv1u_gnb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_gnb_create_tunnel_resp_t *create_tunnel_resp) {
LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, upf_NGu_teid %d\n",
create_tunnel_req->rnti,
create_tunnel_req->num_tunnels,
create_tunnel_req->upf_NGu_teid[0]);
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti,
create_tunnel_req->pdusession_id[i],
create_tunnel_req->upf_NGu_teid[i],
create_tunnel_req->upf_addr[i], 2152,
pdcp_data_req);
LOG_D(GTPU, "create tunnels for RNTI %x, tunnel %d, gnb_NGu_teid 0x%x %u(dec)\n",
create_tunnel_req->rnti, i, teid, teid);
create_tunnel_resp->status=0;
create_tunnel_resp->rnti=create_tunnel_req->rnti;
create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels;
create_tunnel_resp->gnb_NGu_teid[i]=teid;
create_tunnel_resp->pdusession_id[i] = create_tunnel_req->pdusession_id[i];
memcpy(create_tunnel_resp->gnb_addr.buffer,globGtp.instances[compatInst(instance)].foundAddr,
globGtp.instances[compatInst(instance)].foundAddrLen);
create_tunnel_resp->gnb_addr.length= globGtp.instances[compatInst(instance)].foundAddrLen;
}
return !GTPNOK;
}
int ocp_gtpv1u_update_ngu_tunnel(
const instance_t instance,
const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req,
const rnti_t prior_rnti
) {
LOG_D(GTPU, "Start update tunnels for old RNTI %x, new RNTI %x, num_tunnels %d, upf_NGu_teid %d, pdusession_id %d\n",
prior_rnti,
create_tunnel_req->rnti,
create_tunnel_req->num_tunnels,
create_tunnel_req->upf_NGu_teid[0],
create_tunnel_req->pdusession_id[0]);
pthread_mutex_lock(&globGtp.gtp_lock);
auto inst=&globGtp.instances[compatInst(instance)];
if ( inst->ue2te_mapping.find(create_tunnel_req->rnti) == inst->ue2te_mapping.end() ) {
LOG_E(GTPU,"Update not already existing tunnel (new rnti %x, old rnti %x)\n", create_tunnel_req->rnti, prior_rnti);
}
auto it=inst->ue2te_mapping.find(prior_rnti);
if ( it != inst->ue2te_mapping.end() ) {
LOG_W(GTPU,"Update a not existing tunnel, start create the new one (new rnti %x, old rnti %x)\n", create_tunnel_req->rnti, prior_rnti);
pthread_mutex_unlock(&globGtp.gtp_lock);
gtpv1u_gnb_create_tunnel_resp_t tmp;
(void)ocp_gtpv1u_create_ngu_tunnel(instance, create_tunnel_req, &tmp);
return 0;
}
inst->ue2te_mapping[create_tunnel_req->rnti]=it->second;
inst->ue2te_mapping.erase(it);
pthread_mutex_unlock(&globGtp.gtp_lock);
return 0;
}
int ocp_gtpv1u_delete_ngu_tunnel( const instance_t instance,
const gtpv1u_gnb_delete_tunnel_req_t *const req_pP) {
return newGtpuDeleteTunnel(instance, req_pP->rnti);
}
#include <openair2/ENB_APP/enb_paramdef.h>
void *ocp_gtpv1uTask(void *args) {
......@@ -757,6 +827,17 @@ void *ocp_gtpv1uTask(void *args) {
AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
break;
case GTPV1U_GNB_NG_REQ:
strcpy(addr.originHost, GTPV1U_GNB_NG_REQ(message_p).addrStr);
strcpy(addr.originService, GTPV1U_GNB_NG_REQ(message_p).portStr);
AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
break;
case GTPV1U_GNB_DELETE_TUNNEL_REQ:
ocp_gtpv1u_delete_ngu_tunnel(compatInst(ITTI_MSG_DESTINATION_INSTANCE(message_p)),
&GTPV1U_GNB_DELETE_TUNNEL_REQ(message_p));
break;
default:
LOG_E(GTPU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
abort();
......
......@@ -14,6 +14,9 @@ extern "C" {
#define gtpv1u_delete_s1u_tunnel ocp_gtpv1u_delete_s1u_tunnel
#define gtpv1u_create_x2u_tunnel ocp_gtpv1u_create_x2u_tunnel
#define gtpv1u_eNB_task ocp_gtpv1uTask
#define gtpv1u_create_ngu_tunnel ocp_gtpv1u_create_ngu_tunnel
#define gtpv1u_update_ngu_tunnel ocp_gtpv1u_update_ngu_tunnel
#define gtpv1u_delete_ngu_tunnel ocp_gtpv1u_delete_ngu_tunnel
#define gtpv1u_gNB_task ocp_gtpv1uTask
#define TASK_VARIABLE OCP_GTPV1_U
#else
......@@ -58,6 +61,16 @@ int ocp_gtpv1u_create_x2u_tunnel(
const gtpv1u_enb_create_x2u_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_x2u_tunnel_resp_t *const create_tunnel_resp_pP);
int ocp_gtpv1u_create_ngu_tunnel(const instance_t instance,
const gtpv1u_gnb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_gnb_create_tunnel_resp_t *create_tunnel_resp);
int ocp_gtpv1u_update_ngu_tunnel(const instance_t instance,
const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req,
const rnti_t prior_rnti);
int ocp_gtpv1u_delete_ngu_tunnel( const instance_t instance,
const gtpv1u_gnb_delete_tunnel_req_t *const req_pP);
// New API
teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int bearer_id, teid_t teid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment