mac_rlc_primitives.h 12.9 KB
Newer Older
nikaeinn's avatar
nikaeinn 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
/*******************************************************************************
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that 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 OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.

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

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/***************************************************************************
                          mac_rlc_primitives.h  -  description
                             -------------------
 ***************************************************************************/
#ifndef __MAC_RLC_PRIMITIVES_H__
#    define __MAC_RLC_PRIMITIVES_H__

/** @defgroup _mac_rlc_primitives_ MAC Layer Primitives for Communications with RLC
 * @ingroup _openair_mac_layer_specs_
 * @{
This subclause describes the primitives for communications between the RLC and MAC sub-layers.


This clause describes the primitives for communications between the RLC and MAC sub-layers.  It is largely inspired by
3GPP TS 25.321 V4.2.0.
\image html mac_w3g4f_rlc_tx_sequence_diagram.png "MAC-RLC TX Sequence Diagram" width=15cm
\image latex mac_w3g4f_rlc_tx_sequence_diagram.png "MAC-RLC TX Sequence Diagram" width=15cm

MAC-STATUS-Ind (mac_status_ind} primitive indicates to RLC for each logical channel the rate at which it may transfer data to MAC. Parameters
are the number of PDUs that can be transferred in each transmission time interval and the PDU size; it is possible that MAC
would use this primitive to indicate that it expects the current buffer occupancy of the addressed logical channel in order
to provide for optimised TFC selection on transport channels with long transmission time interval. At the UE, MAC-STATUS-Ind
primitive is also used to indicate from MAC to RLC that MAC has requested data transmission by PHY (i.e. PHY-DATA-REQ has
been submitted, see Fig. 11.2.2.1), or that transmission of an RLC PDU on RACH or CPCH has failed due to exceeded preamble
ramping cycle counter.

MAC-STATUS-Resp (mac_status_resp) primitive enables RLC to acknowledge a MAC-STATUS-Ind. It is possible
that RLC would use this primitive to indicate that it has nothing to send or that it is
in a suspended state or to indicate the current buffer occupancy to MAC.

*/
#    include "list.h"
#    include "rrm_constants.h"
//#    include "LAYER2/MAC/defs.h"

#    define MAC_DCCH                              0xCC
#    define MAC_DTCH                              0xDC
//----------------------------------------------------------
// primitives
//----------------------------------------------------------
#    define MAC_DATA_REQ                          0x01
#    define MAC_DATA_IND                          0x02
#    define MAC_STATUS_IND                        0x04
#    define MAC_STATUS_RESP                       0x08
//----------------------------------------------------------
// primitives definition
//----------------------------------------------------------
#    define UE_ID_TYPE_U_RNTI 0xFF
                                // should not be used ?
#    define UE_ID_TYPE_C_RNTI 0xCC

#    define MAC_TX_STATUS_SUCCESSFUL              0x0F
#    define MAC_TX_STATUS_UNSUCCESSFUL            0xF0

#    define MAC_HEADER_MAX_SIZE                   6


// Parameters:
// a)   data:
// -    it contains the RLC layer messages (RLC-PDU) to be transmitted, or the RLC layer messages
//    that have been received by the MAC sub-layer.
//
// b)   no_tb :
// -    indicates the number of transport blocks transmitted by the peer entity within the
//    transmission time interval, based on the TFI value.
//
// c)   buffer_occupancy :
// -    the parameter Buffer Occupancy (BO) indicates for each logical channel the amount of data
//    in number of bytes that is available for transmission and retransmission in RLC layer.
//    When MAC is connected to an AM RLC entity, control PDUs to be transmitted and RLC PDUs
//    outside the RLC Tx window shall also be included in the BO. RLC PDUs that have been
//    transmitted but not negatively acknowledged by the peer entity shall not be included in the BO.
//
// d)   rx_timing_deviation, TDD only:
// -    it contains the RX Timing Deviation as measured by the physical layer for the physical
//    resources carrying the data of the Message Unit. This parameter is optional and only for
//    Indication. It is needed for the transfer of the RX Timing Deviation measurement of RACH
//    transmissions carrying CCCH data to RRC.
//
// e)   no_pdu:
// -    specifies the number of PDUs that the RLC is permitted to transfer to MAC within a
//    transmission time interval.
//
// f)   pdu_size:
// -    specifies the size of PDU that can be transferred to MAC within a transmission time interval.
//
// g)   UE-ID Type Indicator:
// -    indicates the UE-ID type to be included in MAC for a DCCH when it is mapped onto a common
//    transport channel (i.e. FACH, RACH, DSCH in FDD or CPCH). On the UE side UE-ID Type Indicator
//    shall always be set to C-RNTI.
//
// h)   tx_status:
// -    when set to value "transmission unsuccessful" this parameter indicates to RLC that transmission
//    of an RLC PDU failed in the previous Transmission Time Interval, when set to value
//    "transmission successful" this parameter indicates to RLC that the requested RLC PDU(s)
//     has been submitted for transmission by the physical layer.
//
// i)   rlc_info
// -    indicates to MAC the configuration parameters that are critical to TFC selection depending
//    on its mode and the amount of data that could be transmitted at the next TTI. This primitive
//    is meant to insure that MAC can perform TFC selection.
struct rlc_entity_info {
  unsigned char              rlc_protocol_state;
};

struct mac_tx_tb_management {
  // BE CAREFULL TO KEEP THE SAME MAPPING FOR THE 6 FIELDS BELLOW AS FOR  struct mac_tb_req
  unsigned char             *data_ptr;
  unsigned char              first_bit;    // 0 if data starts on byte boundary(b7), 1 if b6, 2 if b5, etc.
  // Previously designed for interlayers optimizations, (avoid aligning on byte boundary)
  // but not used by L1 !, so extra cost for alignement in MAC.
141
  tb_size_t                  tb_size_in_bits;      // L1H does not care of the field first bit any more, so in order to byte
142
143
144
145
146
147
148
149
150
151
152
153
154
  // align the tb we have to know its size

  // for reporting tx status to upper layers
  void           *rlc;
  void            (*rlc_callback) (void *rlcP, unsigned short rlc_tb_type);
  unsigned short             rlc_tb_type;

  unsigned short             log_ch_interface_src; // index of the logical channel interface from which the tb was submitted
  unsigned char              mac_header[MAC_HEADER_MAX_SIZE];      // worst case : tctf(5bits)+UE-Id type(2bits)+UE-Id(16 or 32bits)+C/T(4bits)=43bits max
};

struct mac_rx_tb_management {
  unsigned char             *data_ptr;
155
156
  tb_size_t                  tb_size;      // in bits
  boolean_t                  valid_checksum;
157
158
159
160
161
162
163
  unsigned char              first_bit;    // 0 if data starts on byte boundary(b7), 1 if b6, 2 if b5, etc
};

struct mac_tb_req {
  // BE CAREFULL TO KEEP THE SAME MAPPING FOR THE 6 FIELDS BELLOW AS FOR  struct mac_tx_tb_management
  unsigned char             *data_ptr;
  unsigned char              first_bit;
164
  tb_size_t                  tb_size;
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  // align the tb we have to know its size

  // for reporting tx status to upper layers
  void           *rlc;
  void            (*rlc_callback) (void *rlcP, unsigned short rlc_tb_type);
  unsigned short             rlc_tb_type;

  unsigned char              mac_header[MAC_HEADER_MAX_SIZE];      // worst case : tctf(5bits)+UE-Id type(2bits)+UE-Id(16 or 32bits)+C/T(4bits)=43bits max
};

// MAC-STATUS-Ind/Resp:
/*!\brief
MAC-STATUS-Ind primitive indicates to RLC for each logical channel the rate at which it may transfer data to MAC. Parameters
are the number of PDUs that can be transferred in each transmission time interval and the PDU size; it is possible that MAC
would use this primitive to indicate that it expects the current buffer occupancy of the addressed logical channel in order
to provide for optimised TFC selection on transport channels with long transmission time interval. At the UE, MAC-STATUS-Ind
primitive is also used to indicate from MAC to RLC that MAC has requested data transmission by PHY (i.e. PHY-DATA-REQ has
been submitted, see Fig. 11.2.2.1), or that transmission of an RLC PDU on RACH or CPCH has failed due to exceeded preamble
ramping cycle counter.*/
struct mac_status_ind {
  unsigned short             no_pdu;       /*!< \brief PDUs number*/
  unsigned short             tx_status;    /*!< \brief status is successful or unsuccessful*/
};

/*!\brief
MAC-STATUS-Resp primitive enables RLC to acknowledge a MAC-STATUS-Ind. It is possible
that RLC would use this primitive to indicate that it has nothing to send or that it is
in a suspended state or to indicate the current buffer occupancy to MAC.
*/
struct mac_status_resp {
  unsigned int             buffer_occupancy_in_bytes;   /*!< \brief the parameter Buffer Occupancy (BO) indicates for each logical channel the amount of data in number of bytes that is available for transmission and retransmission in RLC layer. */
  unsigned short             buffer_occupancy_in_pdus;    /*!< xxx*/
gauthier's avatar
gauthier committed
197
198
  uint32_t             head_sdu_creation_time;          
  uint32_t             head_sdu_remaining_size_to_send;
199
  unsigned char     head_sdu_is_segmented;
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
  struct rlc_entity_info rlc_info;             /*!< xxx*/
};

struct mac_tb_ind {
  unsigned char             *data_ptr;
  unsigned short             size;
  unsigned char              error_indication;
  unsigned char              first_bit;    // 0 if data starts on byte boundary(b7), 1 if b6, 2 if b5, etc
};

// MAC-DATA-Req/Ind:



//---------------------
/*! \brief MAC-DATA-Req primitive is used to request that an upper layer PDU be sent using the
    procedures for the information transfer service;
*/
struct mac_data_req {
  list_t                   data;   /*!< contains the RLC layer messages (RLC-PDU) to be transmitted*/
  unsigned int             buffer_occupancy_in_bytes;  /*!< the parameter Buffer Occupancy (BO) indicates for each logical channel the amount of data
                                                   in number of bytes that is available for transmission and retransmission in RLC layer.
                                                   When MAC is connected to an AM RLC entity, control PDUs to be transmitted and RLC PDUs
                                                   outside the RLC Tx window shall also be included in the BO. RLC PDUs that have been
                                                   transmitted but not negatively acknowledged by the peer entity shall not be included in the BO.*/
  unsigned short             buffer_occupancy_in_pdus;   /*!< xxx*/
  struct rlc_entity_info rlc_info;            /*!< indicates to MAC the configuration parameters that are critical to TFC selection depending
						   on its mode and the amount of data that could be transmitted at the next TTI. This primitive
						   is meant to insure that MAC can perform TFC selection.*/
  unsigned char              ue_id_type_indicator;       /*!< indicates the UE-ID type to be included in MAC for a DCCH when it is mapped onto a common
					           transport channel (i.e. FACH, RACH, DSCH in FDD or CPCH). On the UE side UE-ID Type Indicator
					           shall always be set to C-RNTI.*/
};
//---------------------
/*! \brief  MAC-DATA-Ind primitive indicates the arrival of upper layer PDUs received within one
    transmission time interval by means of the information transfer service.*/
struct mac_data_ind {
  list_t                     data;   /*!  the RLC layer messages that have been received by the MAC sub-layer*/
  unsigned short             no_tb;
  unsigned short             tb_size;      // in bits
  //unsigned char              error_indication;
};


//---------------------

//---------------------
struct mac_primitive {
  unsigned char              primitive_type;
  union {
    struct mac_data_req data_req;
    struct mac_status_resp status_resp;
    struct mac_data_ind data_ind;
    //struct mac_status_ind  status_ind;
  } primitive;
};

/** @} */
#endif