intertask_interface_types.h 4.88 KB
Newer Older
1
2
3
4
5
/*
 * 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
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * 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
 */

Cedric Roux's avatar
 
Cedric Roux committed
22
23
24
25
26
27
28
29
30
/** @defgroup _intertask_interface_impl_ Intertask Interface Mechanisms
 * Implementation
 * @ingroup _ref_implementation_
 * @{
 */

#ifndef INTERTASK_INTERFACE_TYPES_H_
#define INTERTASK_INTERFACE_TYPES_H_

31
#include "itti_types.h"
32
#include "platform_types.h"
33

Cedric Roux's avatar
 
Cedric Roux committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Defines to handle bit fields on unsigned long values */
#define UL_BIT_MASK(lENGTH)             ((1UL << (lENGTH)) - 1UL)
#define UL_BIT_SHIFT(vALUE, oFFSET)     ((vALUE) << (oFFSET))
#define UL_BIT_UNSHIFT(vALUE, oFFSET)   ((vALUE) >> (oFFSET))

#define UL_FIELD_MASK(oFFSET, lENGTH)                   UL_BIT_SHIFT(UL_BIT_MASK(lENGTH), (oFFSET))
#define UL_FIELD_INSERT(vALUE, fIELD, oFFSET, lENGTH)   (((vALUE) & (~UL_FIELD_MASK(oFFSET, lENGTH))) | UL_BIT_SHIFT(((fIELD) & UL_BIT_MASK(lENGTH)), oFFSET))
#define UL_FIELD_EXTRACT(vALUE, oFFSET, lENGTH)         (UL_BIT_UNSHIFT((vALUE), (oFFSET)) & UL_BIT_MASK(lENGTH))

/* Definitions of task ID fields */
#define TASK_THREAD_ID_OFFSET   8
#define TASK_THREAD_ID_LENGTH   8

#define TASK_SUB_TASK_ID_OFFSET 0
#define TASK_SUB_TASK_ID_LENGTH 8

/* Defines to extract task ID fields */
51
#define TASK_GET_THREAD_ID(tASKiD)          (itti_desc.tasks_info[tASKiD].thread)
52
#define TASK_GET_PARENT_TASK_ID(tASKiD)     (itti_desc.tasks_info[tASKiD].parent_task)
53
/* Extract the instance from a message */
Cedric Roux's avatar
Cedric Roux committed
54
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE)  ((mESSAGE)->ittiMsgHeader.instance)
55

Cedric Roux's avatar
 
Cedric Roux committed
56
57
58
#include <messages_types.h>

/* This enum defines messages ids. Each one is unique. */
59
typedef enum {
Cedric Roux's avatar
 
Cedric Roux committed
60
61
62
63
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) iD,
#include <messages_def.h>
#undef MESSAGE_DEF

64
  MESSAGES_ID_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
65
66
67
} MessagesIds;

//! Thread id of each task
68
69
typedef enum {
  THREAD_NULL = 0,
Cedric Roux's avatar
 
Cedric Roux committed
70

71
72
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             THREAD_##tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)
Cedric Roux's avatar
 
Cedric Roux committed
73
74
75
76
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

77
78
  THREAD_MAX,
  THREAD_FIRST = 1,
Cedric Roux's avatar
 
Cedric Roux committed
79
80
81
} thread_id_t;

//! Sub-tasks id, to defined offset form thread id
82
typedef enum {
83
84
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             tHREADiD##_THREAD = THREAD_##tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)    sUBtASKiD##_THREAD = THREAD_##tHREADiD,
Cedric Roux's avatar
 
Cedric Roux committed
85
86
87
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF
88
} task_thread_id_t;
Cedric Roux's avatar
 
Cedric Roux committed
89
90

//! Tasks id of each task
91
92
typedef enum {
  TASK_UNKNOWN = 0,
93

94
95
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)    sUBtASKiD,
Cedric Roux's avatar
 
Cedric Roux committed
96
97
98
99
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

100
101
  TASK_MAX,
  TASK_FIRST = 1,
Cedric Roux's avatar
 
Cedric Roux committed
102
103
} task_id_t;

104
typedef union msg_s {
Cedric Roux's avatar
 
Cedric Roux committed
105
106
107
108
109
110
111
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) sTRUCT fIELDnAME;
#include <messages_def.h>
#undef MESSAGE_DEF
} msg_t;

typedef uint16_t MessageHeaderSize;

112
113
114
typedef struct itti_lte_time_s {
  uint32_t frame;
  uint8_t slot;
115
116
} itti_lte_time_t;

Cedric Roux's avatar
 
Cedric Roux committed
117
118
119
/** @struct MessageHeader
 *  @brief Message Header structure for inter-task communication.
 */
120
121
typedef struct MessageHeader_s {
  MessagesIds messageId;          /**< Unique message id as referenced in enum MessagesIds */
Cedric Roux's avatar
 
Cedric Roux committed
122

123
124
125
  task_id_t  originTaskId;        /**< ID of the sender task */
  task_id_t  destinationTaskId;   /**< ID of the destination task */
  instance_t instance;            /**< Task instance for virtualization */
Cedric Roux's avatar
 
Cedric Roux committed
126

127
  MessageHeaderSize ittiMsgSize;         /**< Message size (not including header size) */
128

129
  itti_lte_time_t lte_time;       /**< Reference LTE time */
Cedric Roux's avatar
 
Cedric Roux committed
130
131
132
133
} MessageHeader;

/** @struct MessageDef
 *  @brief Message structure for inter-task communication.
134
135
 *  \internal
 *  The attached attribute \c __packed__ is neccessary, because the memory allocation code expects \ref ittiMsg directly following \ref ittiMsgHeader.
Cedric Roux's avatar
 
Cedric Roux committed
136
 */
137
138
139
typedef struct __attribute__ ((__packed__)) MessageDef_s {
  MessageHeader ittiMsgHeader; /**< Message header */
  msg_t         ittiMsg; /**< Union of payloads as defined in x_messages_def.h headers */
Cedric Roux's avatar
 
Cedric Roux committed
140
141
142
143
} MessageDef;

#endif /* INTERTASK_INTERFACE_TYPES_H_ */
/* @} */