intertask_interface_types.h 4.89 KB
Newer Older
Cedric Roux's avatar
 
Cedric Roux committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************************************

 Eurecom OpenAirInterface
 Copyright(c) 1999 - 2012 Eurecom

 This program is free software; you can redistribute it and/or modify it
 under the terms and conditions of the GNU General Public License,
 version 2, as published by the Free Software Foundation.

 This program is distributed in the hope it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

 The full GNU General Public License is included in this distribution in
 the file called "COPYING".

 Contact Information
 Openair Admin: openair_admin@eurecom.fr
 Openair Tech : openair_tech@eurecom.fr
 Forums       : http://forums.eurecom.fr/openairinterface
 Address      : EURECOM, Campus SophiaTech, 450 Route des Chappes
 06410 Biot FRANCE

 *******************************************************************************/

/** @defgroup _intertask_interface_impl_ Intertask Interface Mechanisms
 * Implementation
 * @ingroup _ref_implementation_
 * @{
 */

#ifndef INTERTASK_INTERFACE_TYPES_H_
#define INTERTASK_INTERFACE_TYPES_H_

40
#include "itti_types.h"
41

Cedric Roux's avatar
 
Cedric Roux committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 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 */
59
#define TASK_GET_THREAD_ID(tASKiD)          (itti_desc.tasks_info[tASKiD].thread)
60
#define TASK_GET_PARENT_TASK_ID(tASKiD)     (itti_desc.tasks_info[tASKiD].parent_task)
61
/* Extract the instance from a message */
Cedric Roux's avatar
Cedric Roux committed
62
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE)  ((mESSAGE)->ittiMsgHeader.instance)
63

Cedric Roux's avatar
 
Cedric Roux committed
64
65
66
67
68
69
70
71
72
#include <messages_types.h>

/* This enum defines messages ids. Each one is unique. */
typedef enum
{
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) iD,
#include <messages_def.h>
#undef MESSAGE_DEF

73
    MESSAGES_ID_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
74
75
76
77
78
} MessagesIds;

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

81
82
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             THREAD_##tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)
Cedric Roux's avatar
 
Cedric Roux committed
83
84
85
86
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

87
    THREAD_MAX,
88
    THREAD_FIRST = 1,
Cedric Roux's avatar
 
Cedric Roux committed
89
90
91
92
93
} thread_id_t;

//! Sub-tasks id, to defined offset form thread id
typedef enum
{
94
95
#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
96
97
98
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF
99
} task_thread_id_t;
Cedric Roux's avatar
 
Cedric Roux committed
100
101
102
103

//! Tasks id of each task
typedef enum
{
104
    TASK_UNKNOWN = 0,
105

106
107
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)    sUBtASKiD,
Cedric Roux's avatar
 
Cedric Roux committed
108
109
110
111
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

112
    TASK_MAX,
113
    TASK_FIRST = 1,
Cedric Roux's avatar
 
Cedric Roux committed
114
115
116
117
118
119
120
121
122
123
124
} task_id_t;

typedef union msg_s
{
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) sTRUCT fIELDnAME;
#include <messages_def.h>
#undef MESSAGE_DEF
} msg_t;

typedef uint16_t MessageHeaderSize;

125
126
127
128
129
130
typedef struct itti_lte_time_s
{
    uint32_t frame;
    uint8_t slot;
} itti_lte_time_t;

Cedric Roux's avatar
 
Cedric Roux committed
131
132
133
134
135
/** @struct MessageHeader
 *  @brief Message Header structure for inter-task communication.
 */
typedef struct MessageHeader_s
{
136
        MessagesIds messageId;          /**< Unique message id as referenced in enum MessagesIds */
Cedric Roux's avatar
 
Cedric Roux committed
137

Cedric Roux's avatar
Cedric Roux committed
138
139
140
        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
141

Cedric Roux's avatar
Cedric Roux committed
142
        MessageHeaderSize ittiMsgSize;         /**< Message size (not including header size) */
143
144

        itti_lte_time_t lte_time;       /**< Reference LTE time */
Cedric Roux's avatar
 
Cedric Roux committed
145
146
147
148
149
150
151
} MessageHeader;

/** @struct MessageDef
 *  @brief Message structure for inter-task communication.
 */
typedef struct MessageDef_s
{
Cedric Roux's avatar
Cedric Roux committed
152
        MessageHeader ittiMsgHeader; /**< Message header */
153
        msg_t         ittiMsg; /**< Union of payloads as defined in x_messages_def.h headers */
Cedric Roux's avatar
 
Cedric Roux committed
154
155
156
157
} MessageDef;

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