Commit 8037229e authored by Raphael Defosseux's avatar Raphael Defosseux

Merge remote-tracking branch 'origin/fix_issue_350_gtpu_init' into develop_integration_2018_w39

parents 7d602d5c e0471628
......@@ -115,11 +115,15 @@ extern "C" {
task_list_t *t=&tasks[destination_task_id];
pthread_mutex_lock (&t->queue_cond_lock);
int ret=itti_send_msg_to_task_locked(destination_task_id, instance, message);
pthread_mutex_unlock (&t->queue_cond_lock);
while ( t->message_queue.size()>0 && t->admin.func != NULL )
while ( t->message_queue.size()>0 && t->admin.func != NULL ) {
if (t->message_queue.size()>1)
LOG_W(TMR,"queue in no thread mode is %ld\n", t->message_queue.size());
pthread_mutex_unlock (&t->queue_cond_lock);
t->admin.func(NULL);
pthread_mutex_lock (&t->queue_cond_lock);
}
pthread_mutex_unlock (&t->queue_cond_lock);
return ret;
}
......@@ -193,6 +197,8 @@ extern "C" {
pthread_mutex_unlock(&t->queue_cond_lock);
LOG_D(TMR,"enter blocking wait for %s\n", itti_get_task_name(task_id));
t->nb_events = epoll_wait(t->epoll_fd,t->events,t->nb_fd_epoll, epoll_timeout);
if ( t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) )
pthread_mutex_lock(&t->queue_cond_lock);
} while (t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) );
AssertFatal (t->nb_events >=0,
......@@ -278,6 +284,18 @@ extern "C" {
"Thread creation for task %d failed!\n", task_id);
pthread_setname_np( t->thread, itti_get_task_name(task_id) );
LOG_I(TMR,"Created Posix thread %s\n", itti_get_task_name(task_id) );
#if 1 // BMC test RT prio
{
int policy;
struct sched_param sparam;
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO)-10;
policy = SCHED_FIFO ;
if (pthread_setschedparam(t->thread, policy, &sparam) != 0) {
LOG_E(TMR,"task %s : Failed to set pthread priority\n", itti_get_task_name(task_id) );
}
}
#endif
return 0;
}
......
......@@ -233,6 +233,11 @@ typedef struct IttiMsgText_s {
#include <openair3/S1AP/s1ap_eNB.h>
//#include <proto.h>
#include <openair3/GTPV1-U/gtpv1u_eNB_task.h>
void *rrc_enb_process_itti_msg(void *);
#include <openair3/SCTP/sctp_eNB_task.h>
#include <openair3/S1AP/s1ap_eNB.h>
/*
static const char *const messages_definition_xml = {
#include <messages_xml.h>
......
......@@ -25,3 +25,4 @@ MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_del
MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_enb_delete_tunnel_resp_t, Gtpv1uDeleteTunnelResp)
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_ind_t, Gtpv1uTunnelDataInd)
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_req_t, Gtpv1uTunnelDataReq)
MESSAGE_DEF(GTPV1U_ENB_S1_REQ, MESSAGE_PRIORITY_MED, Gtpv1uS1Req, gtpv1uS1Req)
......@@ -33,6 +33,7 @@
#define GTPV1U_ENB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDeleteTunnelResp
#define GTPV1U_ENB_TUNNEL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataInd
#define GTPV1U_ENB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataReq
#define GTPV1U_ENB_S1_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uS1Req
#define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF
......@@ -98,4 +99,8 @@ typedef struct gtpv1u_enb_tunnel_data_req_s {
rb_id_t rab_id;
} gtpv1u_enb_tunnel_data_req_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;
} Gtpv1uS1Req;
#endif /* GTPV1_U_MESSAGES_TYPES_H_ */
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7201,29 +7201,24 @@ void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(ctxt_pP, ue_context_pP, 0);
}
//-----------------------------------------------------------------------------
void*
rrc_enb_task(
void* args_p
)
//-----------------------------------------------------------------------------
{
MessageDef *msg_p;
const char *msg_name_p;
instance_t instance;
int result;
SRB_INFO *srb_info_p;
int CC_id;
protocol_ctxt_t ctxt;
void rrc_enb_init(void) {
pthread_mutex_init(&lock_ue_freelist, NULL);
pthread_mutex_init(&rrc_release_freelist, NULL);
memset(&rrc_release_info,0,sizeof(RRC_release_list_t));
itti_mark_task_ready(TASK_RRC_ENB);
LOG_I(RRC,"Entering main loop of RRC message task\n");
while (1) {
}
//-----------------------------------------------------------------------------
void *rrc_enb_process_itti_msg(void *notUsed) {
MessageDef *msg_p;
const char *msg_name_p;
instance_t instance;
int result;
SRB_INFO *srb_info_p;
int CC_id;
protocol_ctxt_t ctxt;
// Wait for a message
itti_receive_msg(TASK_RRC_ENB, &msg_p);
......@@ -7363,9 +7358,28 @@ rrc_enb_task(
result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
if (result != EXIT_SUCCESS) {
LOG_I(RRC, "Failed to free memory (%d)!\n",result);
continue;
}
msg_p = NULL;
return NULL;
}
//-----------------------------------------------------------------------------
void*
rrc_enb_task(
void* args_p
)
//-----------------------------------------------------------------------------
{
rrc_enb_init();
itti_mark_task_ready(TASK_RRC_ENB);
LOG_I(RRC,"Entering main loop of RRC message task\n");
while (1) {
(void) rrc_enb_process_itti_msg(NULL);
}
}
#endif
......
......@@ -336,6 +336,10 @@ rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_t* ue_context_pP);
#if defined(ENABLE_ITTI)
void rrc_enb_init(void);
void *rrc_enb_process_itti_msg(void *);
/**\brief RRC eNB task.
\param void *args_p Pointer on arguments to start the task. */
void *rrc_enb_task(void *args_p);
......
......@@ -49,120 +49,13 @@
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/ran_context.h"
#include "gtpv1u_eNB_defs.h"
#include "gtpv1u_eNB_task.h"
#undef GTP_DUMP_SOCKET
/*
extern boolean_t pdcp_data_req(
const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
const confirm_t confirmP,
const sdu_size_t sdu_buffer_sizeP,
unsigned char *const sdu_buffer_pP,
const pdcp_transmission_mode_t modeP
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,const uint32_t * const sourceL2Id
,const uint32_t * const destinationL2Id
#endif
);
const pdcp_transmission_mode_t modeP);
*/
extern unsigned char NB_eNB_INST;
extern RAN_CONTEXT_t RC;
static int
gtpv1u_eNB_send_init_udp(
uint16_t port_number);
NwGtpv1uRcT
gtpv1u_eNB_log_request(
NwGtpv1uLogMgrHandleT hLogMgr,
uint32_t logLevel,
NwCharT *file,
uint32_t line,
NwCharT *logStr);
NwGtpv1uRcT
gtpv1u_eNB_send_udp_msg(
NwGtpv1uUdpHandleT udpHandle,
uint8_t *buffer,
uint32_t buffer_len,
uint32_t buffer_offset,
uint32_t peerIpAddr,
uint16_t peerPort);
NwGtpv1uRcT
gtpv1u_eNB_process_stack_req(
NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi);
int
data_recv_callback(
uint16_t portP,
uint32_t address,
uint8_t *buffer,
uint32_t length,
void *arg_p);
//int
//gtpv1u_create_tunnel_endpoint(
// gtpv1u_data_t *gtpv1u_data_pP,
// uint8_t ue_idP,
// uint8_t rab_idP,
// char *sgw_ip_addr_pP,
// uint16_t portP);
static NwGtpv1uRcT
gtpv1u_start_timer_wrapper(
NwGtpv1uTimerMgrHandleT tmrMgrHandle,
uint32_t timeoutSec,
uint32_t timeoutUsec,
uint32_t tmrType,
void *timeoutArg,
NwGtpv1uTimerHandleT *hTmr);
static NwGtpv1uRcT
gtpv1u_stop_timer_wrapper(
NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NwGtpv1uTimerHandleT hTmr);
int
gtpv1u_initial_req(
gtpv1u_data_t *gtpv1u_data_pP,
teid_t teidP,
tcp_udp_port_t portP,
uint32_t address);
int
gtpv1u_new_data_req(
uint8_t enb_module_idP,
rnti_t ue_rntiP,
uint8_t rab_idP,
uint8_t *buffer_pP,
uint32_t buf_lenP,
uint32_t buf_offsetP
);
int
gtpv1u_create_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP);
static int
gtpv1u_delete_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP);
static int
gtpv1u_eNB_init(void);
void *
gtpv1u_eNB_task(void *args);
//static gtpv1u_data_t gtpv1u_data_g;
#if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
#include <linux/if.h>
static int gtpv1u_dump_socket_g;
......@@ -215,11 +108,11 @@ static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_len
#endif
//-----------------------------------------------------------------------------
static int gtpv1u_eNB_send_init_udp(uint16_t port_number)
static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req)
{
// Create and alloc new message
MessageDef *message_p;
struct in_addr addr;
struct in_addr addr={0};
message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_INIT);
......@@ -227,12 +120,10 @@ static int gtpv1u_eNB_send_init_udp(uint16_t port_number)
return -1;
}
UDP_INIT(message_p).port = port_number;
//LG UDP_INIT(message_p).address = "0.0.0.0"; //ANY address
addr.s_addr = RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up;
UDP_INIT(message_p).port = req->enb_port_for_S1u_S12_S4_up;
addr.s_addr = req->enb_ip_address_for_S1u_S12_S4_up;
UDP_INIT(message_p).address = inet_ntoa(addr);
LOG_I(GTPU, "Tx UDP_INIT IP addr %s (%x)\n", UDP_INIT(message_p).address,RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up);
LOG_I(GTPU, "Tx UDP_INIT IP addr %s (%x)\n", UDP_INIT(message_p).address,UDP_INIT(message_p).port);
MSC_LOG_EVENT(
MSC_GTPU_ENB,
......@@ -242,6 +133,16 @@ static int gtpv1u_eNB_send_init_udp(uint16_t port_number)
return itti_send_msg_to_task(TASK_UDP, INSTANCE_DEFAULT, message_p);
}
static int gtpv1u_s1_req(
const instance_t instanceP,
const Gtpv1uS1Req * const req) {
memcpy(&RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up,
&req->enb_ip_address_for_S1u_S12_S4_up,
sizeof (req->enb_ip_address_for_S1u_S12_S4_up));
gtpv1u_eNB_send_init_udp(req);
return 0;
}
//-----------------------------------------------------------------------------
NwGtpv1uRcT gtpv1u_eNB_log_request(NwGtpv1uLogMgrHandleT hLogMgr,
uint32_t logLevel,
......@@ -999,23 +900,17 @@ static int gtpv1u_delete_s1u_tunnel(
//-----------------------------------------------------------------------------
static int gtpv1u_eNB_init(void)
int gtpv1u_eNB_init(void)
{
int ret;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uUlpEntityT ulp;
NwGtpv1uUdpEntityT udp;
NwGtpv1uLogMgrEntityT log;
NwGtpv1uTimerMgrEntityT tmr;
// enb_properties_p = enb_config_get()->properties[0];
RC.gtpv1u_data_g = (gtpv1u_data_t*)malloc(sizeof(gtpv1u_data_t));
memset(RC.gtpv1u_data_g, 0, sizeof(gtpv1u_data_t));
RCconfig_gtpu();
RC.gtpv1u_data_g = (gtpv1u_data_t*)calloc(sizeof(gtpv1u_data_t),1);
LOG_I(GTPU, "Initializing GTPU stack %p\n",&RC.gtpv1u_data_g);
//gtpv1u_data_g.gtpv1u_stack;
/* Initialize UE hashtable */
......@@ -1024,7 +919,6 @@ static int gtpv1u_eNB_init(void)
RC.gtpv1u_data_g->teid_mapping = hashtable_create (256, NULL, NULL);
AssertFatal(RC.gtpv1u_data_g->teid_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create\n");
// RC.gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up = enb_properties_p->enb_ipv4_address_for_S1U;
RC.gtpv1u_data_g->ip_addr = NULL;
//gtpv1u_data_g.udp_data;
RC.gtpv1u_data_g->seq_num = 0;
......@@ -1089,35 +983,21 @@ static int gtpv1u_eNB_init(void)
}
#endif
ret = gtpv1u_eNB_send_init_udp(RC.gtpv1u_data_g->enb_port_for_S1u_S12_S4_up);
if (ret < 0) {
return ret;
}
LOG_D(GTPU, "Initializing GTPV1U interface for eNB: DONE\n");
return 0;
}
//-----------------------------------------------------------------------------
void *gtpv1u_eNB_task(void *args)
{
int rc = 0;
instance_t instance;
//const char *msg_name_p;
rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
itti_mark_task_ready(TASK_GTPV1_U);
MSC_START_USE();
while(1) {
void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
/* Trying to fetch a message from the message queue.
* If the queue is empty, this function will block till a
* message is sent to the task.
*/
instance_t instance;
MessageDef *received_message_p = NULL;
int rc = 0;
itti_receive_msg(TASK_GTPV1_U, &received_message_p);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_IN);
DevAssert(received_message_p != NULL);
......@@ -1127,6 +1007,9 @@ void *gtpv1u_eNB_task(void *args)
switch (ITTI_MSG_ID(received_message_p)) {
case GTPV1U_ENB_S1_REQ:
gtpv1u_s1_req(instance, &received_message_p->ittiMsg.gtpv1uS1Req);
case GTPV1U_ENB_DELETE_TUNNEL_REQ: {
gtpv1u_delete_s1u_tunnel(instance, &received_message_p->ittiMsg.Gtpv1uDeleteTunnelReq);
}
......@@ -1258,6 +1141,22 @@ void *gtpv1u_eNB_task(void *args)
AssertFatal(rc == EXIT_SUCCESS, "Failed to free memory (%d)!\n", rc);
received_message_p = NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_OUT);
return NULL;
}
//-----------------------------------------------------------------------------
void *gtpv1u_eNB_task(void *args)
{
int rc = 0;
rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
itti_mark_task_ready(TASK_GTPV1_U);
MSC_START_USE();
while(1) {
(void) gtpv1u_eNB_process_itti_msg (NULL);
}
return NULL;
......
......@@ -97,8 +97,6 @@ typedef struct gtpv1u_data_s {
//RB_HEAD(gtpv1u_ue_map, gtpv1u_ue_data_s) gtpv1u_ue_map_head;
/* Local IP address to use */
in_addr_t enb_ip_address_for_S1u_S12_S4_up;
char *ip_addr;
tcp_udp_port_t enb_port_for_S1u_S12_S4_up;
/* UDP internal data */
//udp_data_t udp_data;
......
......@@ -40,6 +40,8 @@ gtpv1u_new_data_req(
uint32_t buf_len,
uint32_t buf_offset);*/
int gtpv1u_eNB_init(void);
void *gtpv1u_eNB_process_itti_msg(void*);
void *gtpv1u_eNB_task(void *args);
int
......
......@@ -286,19 +286,20 @@ void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind)
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
}
void *s1ap_eNB_task(void *arg)
void s1ap_eNB_init(void)
{
MessageDef *received_msg = NULL;
int result;
S1AP_DEBUG("Starting S1AP layer\n");
s1ap_eNB_prepare_internal_data();
itti_mark_task_ready(TASK_S1AP);
MSC_START_USE();
}
while (1) {
void *s1ap_eNB_process_itti_msg(void* notUsed)
{
MessageDef *received_msg = NULL;
int result;
itti_receive_msg(TASK_S1AP, &received_msg);
switch (ITTI_MSG_ID(received_msg)) {
......@@ -413,6 +414,16 @@ void *s1ap_eNB_task(void *arg)
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
received_msg = NULL;
return NULL;
}
void *s1ap_eNB_task(void *arg)
{
s1ap_eNB_init();
while (1) {
(void) s1ap_eNB_process_itti_msg(NULL);
}
return NULL;
......
......@@ -39,6 +39,8 @@ extern s1ap_eNB_config_t s1ap_config;
#define EPC_MODE_ENABLED s1ap_config.mme_enabled
void *s1ap_eNB_process_itti_msg(void*);
void s1ap_eNB_init(void);
void *s1ap_eNB_task(void *arg);
uint32_t s1ap_generate_eNB_id(void);
......
......@@ -1039,15 +1039,9 @@ sctp_eNB_flush_sockets(
}
}
//------------------------------------------------------------------------------
void *sctp_eNB_task(void *arg)
void sctp_eNB_init(void)
{
int nb_events;
struct epoll_event *events;
MessageDef *received_msg = NULL;
int result;
SCTP_DEBUG("Starting SCTP layer\n");
STAILQ_INIT(&sctp_cnx_list);
......@@ -1055,7 +1049,16 @@ void *sctp_eNB_task(void *arg)
itti_mark_task_ready(TASK_SCTP);
MSC_START_USE();
while (1) {
}
//------------------------------------------------------------------------------
void *sctp_eNB_process_itti_msg(void *notUsed)
{
int nb_events;
struct epoll_event *events;
MessageDef *received_msg = NULL;
int result;
itti_receive_msg(TASK_SCTP, &received_msg);
/* Check if there is a packet to handle */
......@@ -1142,6 +1145,17 @@ void *sctp_eNB_task(void *arg)
nb_events = itti_get_events(TASK_SCTP, &events);
/* Now handle notifications for other sockets */
sctp_eNB_flush_sockets(events, nb_events);
return NULL;
}
//------------------------------------------------------------------------------
void *sctp_eNB_task(void *arg)
{
sctp_eNB_init();
while (1) {
(void) sctp_eNB_process_itti_msg(NULL);
}
return NULL;
......
......@@ -22,6 +22,8 @@
#ifndef SCTP_ENB_TASK_H_
#define SCTP_ENB_TASK_H_
void sctp_eNB_init(void);
void *sctp_eNB_process_itti_msg(void *);
void *sctp_eNB_task(void *arg);
#endif /* SCTP_ENB_TASK_H_ */
......@@ -321,7 +321,15 @@ void signal_handler(int sig) {
#define KBLU "\x1B[34m"
#define RESET "\033[0m"
#if defined(ENABLE_ITTI)
void signal_handler_itti(int sig) {
// Call exit function
char msg[256];
memset(msg, 0, 256);
sprintf(msg, "caught signal %s\n", strsignal(sig));
exit_function(__FILE__, __FUNCTION__, __LINE__, msg);
}
#endif
void exit_function(const char* file, const char* function, const int line, const char* s)
{
......@@ -954,6 +962,11 @@ int main( int argc, char **argv )
signal(SIGINT, signal_handler);
#endif
#if defined(ENABLE_ITTI)
signal(SIGINT, signal_handler_itti);
signal(SIGTERM, signal_handler_itti);
signal(SIGABRT, signal_handler_itti);
#endif
check_clock();
......
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