diff --git a/common/utils/ocp_itti/itti.md b/common/utils/ocp_itti/itti.md new file mode 100644 index 0000000000..89bc3ee29f --- /dev/null +++ b/common/utils/ocp_itti/itti.md @@ -0,0 +1,91 @@ +# interthread interface (ITTI) + +A Middleware called “itti” (interthread interface) provides classical send/receive message queues between threads. + +A simpler thread safe message queue is available in the thread-pool, as it is a required lower level feature. + +ITTI is providing more feature, to be used as the thread event main loop. + +It is also made for strong type definition is source code. + +It is able to add in the managed events: external sockets, timers + +All queues are created in .h files, as static permanent queues, nevertheless the possibility to add queues during runtime is available. + +The queues are called tasks because it is often read in a single thread that have the same name. + +# API definition + +## itti_send_msg_to_task, itti_receive_msg, itti_poll_msg + +Standard messages queues, thread safe +The reader is responsible of freeing the message + +## itti_subscribe_event_fd, itti_get_events + +Add external sockets to itti based main loop + +## timer_setup timer_remove + +When a timer expire, it adds a message in a itti queue + +## itti_terminate_tasks + +Calling this function push a “terminate” message on each itti queue + +# Example code of a thread using ITTI + +``` +Thread_aLayer_main(void * context) { + // initialize the layer data + // and register in itti the external sockets (like S1AP, GTP) + aLayer_init(); + while (1) { + MessageDef * msg + itti_receive_msg(TASK_aLayer, &msg); + // itti receive released, so we have incoming data + // Can be a itti message + if ( msg != NULL) { + switch(ITTI_MSG_ID(msg)) { + case …: + processThisMsgType1(msg); + break; + case …: + processThisMsgType2(msg); + break; + } + Itti_free(msg); + } + // or data/event on external entries (sockets) + Struct eppol_events* events; + int nbEvents=itti_get_events(TASK_aLayer, &events); + if ( nbEvents > 0) + processLayerEvents(events, nbEvents); + } +} + + +``` + +# Current usage in OpenAir + +## UDP, SCTP + +Simple threads that interface itti internal messages to Linux + +## GTPV1-U, S1AP + +Threads to implement S1AP and GTP protocols + +## PDCP + +4G Pdcp is not following itti design pattern, but it uses itti internally , 5G PDCP uses ad hoc design + +## RRC + +Implements 3GPP Rrc features +Interfaces the layer 1 and the above itti tasks + +## X2, ENP_APP (configuration), L1L2 + +Are declared itti queues with a dedicated thread, but they are almost empty \ No newline at end of file diff --git a/doc/F1-design.md b/doc/F1-design.md index c1d0d1f798..343dd63464 100644 --- a/doc/F1-design.md +++ b/doc/F1-design.md @@ -24,7 +24,7 @@ https://gitlab.eurecom.fr/oai/openairinterface5g/-/wikis/f1-interface # 2. Common multi-threading architecture # -The CU and DU interfaces are based on ITTI threads (see oai/common/utils/ocp_itti/itti.md when it will be written, draft available: https://docbox.etsi.org/Workshop/2018/201812_ETSI_OAI/TRAINING/OPENCELLS_THOMAS.pdf) +The CU and DU interfaces are based on ITTI threads (see oai/common/utils/ocp_itti/itti.md) All OAI upper layers use the ITTI framework to run isolated threads dedicated to one feature. The lower layers adopt case by case specific software architecture. diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 063ba32fb6..1b1ed3ced9 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -342,7 +342,7 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, msg->rrc_container=(uint8_t*) (msg+1); // Made extra room after the struct with itti_alloc_msg_sized() memcpy(msg->rrc_container, sduP, sdu_lenP); msg->rrc_container_length=sdu_lenP; - itti_send_msg(TASK_DU_F1, 0, tmp); + itti_send_msg_to_task(TASK_DU_F1, 0, tmp); return(0); }