defs.h 25.6 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
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
 * 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
 */
ghaddab's avatar
ghaddab committed
21

22 23 24 25 26 27 28 29 30 31
/*
  \author R. Knopp, F. Kaltenberger
  \company EURECOM
  \email knopp@eurecom.fr
*/

#ifndef __openair_SCHED_H__
#define __openair_SCHED_H__

#include "PHY/defs.h"
32
#include "PHY_INTERFACE/defs.h"
knopp's avatar
knopp committed
33

34
enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0,
35
                    TOP_LEVEL_SCHEDULER_THREAD_INDEX,
36
                    DLC_SCHED_THREAD_INDEX,
37 38
                    openair_SCHED_NB_THREADS
                  }; // do not modify this line
39 40 41 42 43


#define OPENAIR_THREAD_PRIORITY        255


44
#define OPENAIR_THREAD_STACK_SIZE     PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6
45
//#define DLC_THREAD_STACK_SIZE        4096 //DLC stack size
fnabet's avatar
fnabet committed
46
//#define UE_SLOT_PARALLELISATION
47 48

enum openair_SCHED_STATUS {
49 50 51 52 53
  openair_SCHED_STOPPED=1,
  openair_SCHED_STARTING,
  openair_SCHED_STARTED,
  openair_SCHED_STOPPING
};
54 55 56 57 58 59 60 61 62 63 64 65 66 67

enum openair_ERROR {
  // HARDWARE CAUSES
  openair_ERROR_HARDWARE_CLOCK_STOPPED= 1,

  // SCHEDULER CAUSE
  openair_ERROR_OPENAIR_RUNNING_LATE,
  openair_ERROR_OPENAIR_SCHEDULING_FAILED,

  // OTHERS
  openair_ERROR_OPENAIR_TIMING_OFFSET_OUT_OF_BOUNDS,
};

enum openair_SYNCH_STATUS {
68 69 70 71
  openair_NOT_SYNCHED=1,
  openair_SYNCHED,
  openair_SCHED_EXIT
};
72

73 74 75 76 77
enum openair_HARQ_TYPE {
  openair_harq_DL = 0,
  openair_harq_UL,
  openair_harq_RA
};
78 79 80 81 82 83 84 85 86 87

#define DAQ_AGC_ON 1
#define DAQ_AGC_OFF 0


/** @addtogroup _PHY_PROCEDURES_
 * @{
 */


88 89

/*! \brief Top-level entry routine for eNB procedures.  Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required).  On odd slots, it generate TX waveform for the following subframe.
knopp's avatar
knopp committed
90
  @param subframe Index of current subframe (0-9)
91 92
  @param phy_vars_eNB Pointer to eNB variables on which to act
  @param abstraction_flag Indicator of PHY abstraction
93
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
94
  @param *phy_vars_rn pointer to RN variables
95
*/
knopp's avatar
knopp committed
96
void phy_procedures_eNB_lte(uint8_t subframe,PHY_VARS_eNB **phy_vars_eNB,uint8_t abstraction_flag, relaying_type_t r_type, PHY_VARS_RN *phy_vars_rn);
97 98

/*! \brief Top-level entry routine for UE procedures.  Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required).  On odd slots, it generate TX waveform for the following subframe.
99 100 101 102
  @param phy_vars_ue Pointer to UE variables on which to act
  @param eNB_id ID of eNB on which to act
  @param abstraction_flag Indicator of PHY abstraction
  @param mode calibration/debug mode
103
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
104
  @param *phy_vars_rn pointer to RN variables
105
*/
106
void phy_procedures_UE_lte(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn);
107

Cedric Roux's avatar
Cedric Roux committed
108
#if defined(Rel10) || defined(Rel14)
109
/*! \brief Top-level entry routine for relay node procedures when acting as eNB. This proc will make us of the existing eNB procs.
110 111 112 113 114
  @param last_slot Index of last slot (0-19)
  @param next_slot Index of next_slot (0-19)
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
*/
int phy_procedures_RN_eNB_TX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type);
115
/*! \brief Top-level entry routine for relay node procedures actinf as UE. This proc will make us of the existing UE procs.
116 117 118 119 120 121
  @param last_slot Index of last slot (0-19)
  @param next_slot Index of next_slot (0-19)
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
*/
int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type);
#endif
122

123
/*! \brief Scheduling for UE TX procedures in normal subframes.
124
  @param phy_vars_ue Pointer to UE variables on which to act
125
  @param proc Pointer to RXn-TXnp4 proc information
126 127 128
  @param eNB_id Local id of eNB on which to act
  @param abstraction_flag Indicator of PHY abstraction
  @param mode calib/normal mode
129
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
130
*/
131
void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type);
132
/*! \brief Scheduling for UE RX procedures in normal subframes.
133 134
  @param last_slot Index of last slot (0-19)
  @param phy_vars_ue Pointer to UE variables on which to act
135
  @param proc Pointer to RXn_TXnp4 proc information
136 137 138
  @param eNB_id Local id of eNB on which to act
  @param abstraction_flag Indicator of PHY abstraction
  @param mode calibration/debug mode
139
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
140
  @param phy_vars_rn pointer to RN variables
141
*/
142
int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn);
143 144 145 146 147 148 149 150 151 152 153 154 155

/*! \brief Scheduling for UE Sidelink RX procedures in normal subframes.
  @param ue Pointer to UE variables on which to act
  @param proc Pointer to RXn_TXnp4 proc information
*/
void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc);

/*! \brief Scheduling for UE Sidelink TX procedures in normal subframes.
  @param ue Pointer to UE variables on which to act
  @param proc Pointer to RXn_TXnp4 proc information
*/
void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc);

156 157 158
int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,
                                              uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,
                                              relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn);
fnabet's avatar
fnabet committed
159
#ifdef UE_SLOT_PARALLELISATION
160
void *UE_thread_slot1_dl_processing(void *arg);
fnabet's avatar
fnabet committed
161
#endif
162

163
/*! \brief Scheduling for UE TX procedures in TDD S-subframes.
164 165 166
  @param phy_vars_ue Pointer to UE variables on which to act
  @param eNB_id Local id of eNB on which to act
  @param abstraction_flag Indicator of PHY abstraction
167
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
168
*/
knopp's avatar
knopp committed
169
void phy_procedures_UE_S_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type);
170

171
/*! \brief Scheduling for UE RX procedures in TDD S-subframes.
172 173 174
  @param phy_vars_ue Pointer to UE variables on which to act
  @param eNB_id Local id of eNB on which to act
  @param abstraction_flag Indicator of PHY abstraction
175
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
176
*/
177
void phy_procedures_UE_S_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag, relaying_type_t r_type);
178

179
/*! \brief Scheduling for eNB TX procedures in normal subframes.
180 181
  @param phy_vars_eNB Pointer to eNB variables on which to act
  @param abstraction_flag Indicator of PHY abstraction
182
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
183
  @param phy_vars_rn pointer to the RN variables
184
  @param do_meas Do inline timing measurement
185
*/
186
void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn,int do_meas);
187

188
/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes.
189
  @param phy_vars_eNB Pointer to eNB variables on which to act
knopp's avatar
knopp committed
190
  @param proc Pointer to RXn-TXnp4 proc information
191
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
192
*/
193
void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type);
194 195 196

/*! \brief Scheduling for eNB TX procedures in TDD S-subframes.
  @param phy_vars_eNB Pointer to eNB variables on which to act
knopp's avatar
knopp committed
197
  @param proc Pointer to RXn-TXnp4 proc information
198 199 200 201 202 203 204
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
*/

/*! \brief Scheduling for eNB RX common procedures in normal subframes.
  @param phy_vars_eNB Pointer to eNB variables on which to act
  @param abstraction_flag Indicator of PHY abstraction
*/
205
void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc);
206

207
/*! \brief Scheduling for eNB TX procedures in TDD S-subframes.
208
  @param phy_vars_eNB Pointer to eNB variables on which to act
209
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
210
*/
211

212
void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB,relaying_type_t r_type);
213

214
/*! \brief Scheduling for eNB RX procedures in TDD S-subframes.
215
  @param phy_vars_eNB Pointer to eNB variables on which to act
216
  @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
217
*/
218
void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type);
219

220
/*! \brief Scheduling for eNB PRACH RX procedures
221
  @param phy_vars_eNB Pointer to eNB variables on which to act
222
  @param br_flag indicator for eMTC PRACH
223
*/
224 225 226 227 228
void prach_procedures(PHY_VARS_eNB *eNB,
#ifdef Rel14
		      int br_flag
#endif
		      );
229
/*! \brief Function to compute subframe type as a function of Frame type and TDD Configuration (implements Table 4.2.2 from 36.211, p.11 from version 8.6) and subframe index.
230 231
  @param frame_parms Pointer to DL frame parameter descriptor
  @param subframe Subframe index
232
  @returns Subframe type (DL,UL,S)
233
*/
234 235


236
lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe);
237

238

239 240 241 242 243 244 245
/*! \brief Function to compute which type of DCIs to detect in the given subframe
  @param frame_parms Pointer to DL frame parameter descriptor
  @param subframe Subframe index
  @returns DCI detetion mode type (no DCIs, uplink DCIs, downlink DCIs, both uplink and downlink DCIs)
 */
dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe);

246
/*! \brief Function to compute subframe type as a function of Frame type and TDD Configuration (implements Table 4.2.2 from 36.211, p.11 from version 8.6) and subframe index.  Same as subframe_select, except that it uses the Mod_id and is provided as a service to the MAC scheduler.
247
  @param Mod_id Index of eNB
knopp's avatar
knopp committed
248
  @param CC_id Component Carrier Index
249
  @param subframe Subframe index
250
  @returns Subframe type (DL,UL,S)
251
*/
knopp's avatar
knopp committed
252
lte_subframe_t get_subframe_direction(uint8_t Mod_id, uint8_t CC_id,uint8_t subframe);
253

254
/*! \brief Function to indicate PHICH transmission subframes.  Implements Table 9.1.2-1 for TDD.
255 256 257 258
  @param frame_parms Pointer to DL frame parameter descriptor
  @param subframe Subframe index
  @returns 1 if PHICH can be transmitted in subframe (always 1 for FDD)
*/
259
uint32_t is_phich_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe);
260

261
/*! \brief Function to compute timing of Msg3 transmission on UL-SCH (first UE transmission in RA procedure). This implements the timing in paragraph a) from Section 6.1.1 in 36.213 (p. 17 in version 8.6).  Used by eNB upon transmission of random-access response (RA_RNTI) to program corresponding ULSCH reception procedure.  Used by UE upon reception of random-access response (RA_RNTI) to program corresponding ULSCH transmission procedure.  This does not support the UL_delay field in RAR (always assumed to be 0).
262
  @param frame_parms Pointer to DL frame parameter descriptor
263
  @param current_subframe Index of subframe where RA_RNTI was received
264 265 266 267 268
  @param current_frame Index of frame where RA_RNTI was received
  @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD)
  @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2)
*/
void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms,
269 270 271 272
                    uint8_t current_subframe,
                    uint32_t current_frame,
                    uint32_t *frame,
                    uint8_t *subframe);
273

274
/*! \brief Function to compute timing of Msg3 retransmission on UL-SCH (first UE transmission in RA procedure).
275
  @param frame_parms Pointer to DL frame parameter descriptor
276
  @param current_subframe Index of subframe where RA_RNTI was received
277 278 279 280 281
  @param current_frame Index of frame where RA_RNTI was received
  @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD)
  @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2)
*/
void get_Msg3_alloc_ret(LTE_DL_FRAME_PARMS *frame_parms,
282 283 284 285
                        uint8_t current_subframe,
                        uint32_t current_frame,
                        uint32_t *frame,
                        uint8_t *subframe);
286

287
/*! \brief Get ULSCH harq_pid for Msg3 from RAR subframe.  This returns n+k mod 10 (k>6) and corresponds to the rule in Section 6.1.1 from 36.213
288 289 290 291 292
   @param frame_parms Pointer to DL Frame Parameters
   @param frame Frame index
   @param current_subframe subframe of RAR transmission
   @returns harq_pid (0 ... 7)
 */
293
uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe);
294

295
/*! \brief Get ULSCH harq_pid from PHICH subframe
296 297 298 299 300
   @param frame_parms Pointer to DL Frame Parameters
   @param subframe subframe of PHICH
   @returns harq_pid (0 ... 7)
 */

301
/*! \brief Function to indicate failure of contention resolution or RA procedure.  It places the UE back in PRACH mode.
302
    @param Mod_id Instance index of UE
knopp's avatar
knopp committed
303
    @param CC_id Component Carrier Index
304 305
    @param eNB_index Index of eNB
 */
knopp's avatar
knopp committed
306
void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
307

308
/*! \brief Function to indicate success of contention resolution or RA procedure.
309
    @param Mod_id Instance index of UE
knopp's avatar
knopp committed
310
    @param CC_id Component Carrier Index
311 312
    @param eNB_index Index of eNB
 */
knopp's avatar
knopp committed
313
void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
314

315
uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
316

317
/*! \brief Get PDSCH subframe (n+k) from PDCCH subframe n using relationship from Table 8-2 from 36.213
318 319 320 321
   @param frame_parms Pointer to DL Frame Parameters
   @param n subframe of PDCCH
   @returns PDSCH subframe (0 ... 7) (note: this is n+k from Table 8-2)
 */
322
uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n);
323

324 325

/*! \brief Compute ACK/NACK information for PUSCH/PUCCH for UE transmission in subframe n. This function implements table 10.1-1 of 36.213, p. 69.
326 327 328 329 330 331
  @param frame_parms Pointer to DL frame parameter descriptor
  @param harq_ack Pointer to dlsch_ue harq_ack status descriptor
  @param subframe Subframe for UE transmission (n in 36.213)
  @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH
  @returns status indicator for PUCCH/PUSCH transmission
*/
Bilel's avatar
Bilel committed
332
uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,harq_status_t *harq_ack,uint8_t subframe_tx,uint8_t subframe_rx,uint8_t *o_ACK, uint8_t cw_idx);
333

334 335 336 337 338 339 340 341 342
/*! \brief Reset ACK/NACK information
  @param frame_parms Pointer to DL frame parameter descriptor
  @param harq_ack Pointer to dlsch_ue harq_ack status descriptor
  @param subframe Subframe for UE transmission (n in 36.213)
  @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH
  @returns status indicator for PUCCH/PUSCH transmission
*/
uint8_t reset_ack(LTE_DL_FRAME_PARMS *frame_parms,
                harq_status_t *harq_ack,
Bilel's avatar
Bilel committed
343 344
                unsigned char subframe_tx,
                unsigned char subframe_rx,
345
                unsigned char *o_ACK,
Bilel's avatar
Bilel committed
346
                uint8_t *pN_bundled,
347
                uint8_t cw_idx);
348

349
/*! \brief Compute UL ACK subframe from DL subframe. This is used to retrieve corresponding DLSCH HARQ pid at eNB upon reception of ACK/NAK information on PUCCH/PUSCH.  Derived from Table 10.1-1 in 36.213 (p. 69 in version 8.6)
350 351 352 353 354
  @param frame_parms Pointer to DL frame parameter descriptor
  @param subframe Subframe for UE transmission (n in 36.213)
  @param ACK_index TTI bundling index (0,1)
  @returns Subframe index for corresponding DL transmission
*/
355
uint8_t ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe,uint8_t ACK_index);
356

357
/*! \brief Computes number of DL subframes represented by a particular ACK received on UL (M from Table 10.1-1 in 36.213, p. 69 in version 8.6)
358 359 360 361
  @param frame_parms Pointer to DL frame parameter descriptor
  @param subframe Subframe for UE transmission (n in 36.213)
  @returns Number of DL subframes (M)
*/
362
uint8_t ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe);
363

364
/*! \brief Indicates the SR TXOp in current subframe.  Implements Table 10.1-5 from 36.213.
365
  @param phy_vars_ue Pointer to UE variables
366
  @param proc Pointer to RXn_TXnp4 thread context
367 368 369
  @param eNB_id ID of eNB which is to receive the SR
  @returns 1 if TXOp is active.
*/
370
uint8_t is_SR_TXOp(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id);
371

372
/*! \brief Indicates the SR TXOp in current subframe for eNB and particular UE index.  Implements Table 10.1-5 from 36.213.
373 374 375 376
  @param phy_vars_eNB Pointer to eNB variables
  @param UE_id ID of UE which may be issuing the SR
  @returns 1 if TXOp is active.
*/
knopp's avatar
knopp committed
377
uint8_t is_SR_subframe(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t UE_id);
378

379
/*! \brief Gives the UL subframe corresponding to a PDDCH order in subframe n
380
  @param frame_parms Pointer to DL frame parameters
knopp's avatar
knopp committed
381
  @param proc Pointer to RXn-TXnp4 proc information
382 383 384
  @param n subframe of PDCCH
  @returns UL subframe corresponding to pdcch order
*/
385
uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n);
386

387
/*! \brief Gives the UL frame corresponding to a PDDCH order in subframe n
388 389 390 391 392
  @param frame_parms Pointer to DL frame parameters
  @param frame Frame of received PDCCH
  @param n subframe of PDCCH
  @returns UL frame corresponding to pdcch order
*/
knopp's avatar
knopp committed
393
uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n);
394 395


396
uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1);
397 398


399 400 401 402 403
int8_t find_ue_dlsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
int8_t find_ue_ulsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);

//int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
//int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rnti);
404

405
void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance);
406
void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint16_t timing_advance);
407

knopp's avatar
knopp committed
408
unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb);
409

410
void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
411

412
/*! \brief This function retrives the resource (n1_pucch) corresponding to a PDSCH transmission in
413 414 415
subframe n-4 which is acknowledged in subframe n (for FDD) according to n1_pucch = Ncce + N1_pucch.  For
TDD, this routine computes the complex procedure described in Section 10.1 of 36.213 (through tables 10.1-1,10.1-2)
@param phy_vars_ue Pointer to UE variables
416
@param proc Pointer to RXn-TXnp4 proc information
417
@param harq_ack Pointer to dlsch_ue harq_ack status descriptor
418 419 420 421 422
@param eNB_id Index of eNB
@param b Pointer to PUCCH payload (b[0],b[1])
@param SR 1 means there's a positive SR in parallel to ACK/NAK
@returns n1_pucch
*/
423
uint16_t get_n1_pucch(PHY_VARS_UE *phy_vars_ue,
424
		      UE_rxtx_proc_t *proc,
425
                      harq_status_t *harq_ack,
426 427 428
                      uint8_t eNB_id,
                      uint8_t *b,
                      uint8_t SR);
429

430
/*! \brief This function retrives the resource (n1_pucch) corresponding to a PDSCH transmission in
431 432
subframe n-4 which is acknowledged in subframe n (for FDD) according to n1_pucch = Ncce + N1_pucch.  For
TDD, this routine computes the procedure described in Section 10.1 of 36.213 (through tables 10.1-1,10.1-2)
knopp's avatar
knopp committed
433 434
@param phy_vars_eNB Pointer to eNB variables
@param proc Pointer to RXn-TXnp4 proc information
435 436 437 438 439 440 441 442 443
@param eNB_id Index of eNB
@param subframe Index of subframe
@param b Pointer to PUCCH payload (b[0],b[1])
@param n1_pucch0 Pointer to n1_pucch0
@param n1_pucch1 Pointer to n1_pucch1
@param n1_pucch2 Pointer to n1_pucch2
@param n1_pucch3 Pointer to n1_pucch3
*/
void get_n1_pucch_eNB(PHY_VARS_eNB *phy_vars_eNB,
knopp's avatar
knopp committed
444
		      eNB_rxtx_proc_t *proc,
445 446 447 448 449
                      uint8_t UE_id,
                      int16_t *n1_pucch0,
                      int16_t *n1_pucch1,
                      int16_t *n1_pucch2,
                      int16_t *n1_pucch3);
450 451


452
/*! \brief This function retrieves the harq_pid of the corresponding DLSCH process and updates the error statistics of the DLSCH based on the received ACK info from UE along with the round index.  It also performs the fine-grain rate-adaptation based on the error statistics derived from the ACK/NAK process.
453 454
  @param UE_id Local UE index on which to act
  @param phy_vars_eNB Pointer to eNB variables on which to act
knopp's avatar
knopp committed
455
  @param proc Pointer to RXn-TXnp4 proc information
456 457 458 459 460
  @param pusch_flag Indication that feedback came from PUSCH
  @param pucch_payload Resulting payload from pucch
  @param pucch_sel Selection of n1_pucch0 or n1_pucch1 (TDD specific)
  @param SR_payload Indication of SR presence (TDD specific)
*/
461 462
void process_HARQ_feedback(uint8_t UE_id,
                           PHY_VARS_eNB *phy_vars_eNB,
knopp's avatar
knopp committed
463
			   eNB_rxtx_proc_t *proc,
464 465 466 467
                           uint8_t pusch_flag,
                           uint8_t *pucch_payload,
                           uint8_t pucch_sel,
                           uint8_t SR_payload);
468

469
/*! \brief This function retrieves the PHY UE mode. It is used as a helper function for the UE MAC.
470
  @param Mod_id Local UE index on which to act
knopp's avatar
knopp committed
471
  @param CC_id Component Carrier Index
472 473
  @param eNB_index ID of eNB
  @returns UE mode
474
*/
knopp's avatar
knopp committed
475
UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
476

477
/*! \brief This function implements the power control mechanism for PUCCH from 36.213.
478
    @param phy_vars_ue PHY variables
479
    @param proc Pointer to proc descriptor
480 481 482 483
    @param eNB_id Index of eNB
    @param pucch_fmt Format of PUCCH that is being transmitted
    @returns Transmit power
 */
484
int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt);
485

486
/*! \brief This function implements the power control mechanism for PUCCH from 36.213.
487
    @param phy_vars_ue PHY variables
488
    @param proc Pointer to proc descriptor
489 490 491 492
    @param eNB_id Index of eNB
    @param j index of type of PUSCH (SPS, Normal, Msg3)
    @returns Transmit power
 */
493
void pusch_power_cntl(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag);
494

Bilel's avatar
Bilel committed
495 496 497 498 499 500 501 502 503
/*! \brief This function implements the power control mechanism for SRS from 36.213.
    @param phy_vars_ue PHY variables
    @param proc Pointer to proc descriptor
    @param eNB_id Index of eNB
    @param j index of type of PUSCH (SPS, Normal, Msg3)
    @returns Transmit power
 */
void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag);

knopp's avatar
knopp committed
504 505
void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id);

506
int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index);
507

508 509
void schedule_response(Sched_Rsp_t *Sched_INFO);

510
LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti);
511

knopp's avatar
knopp committed
512 513


514 515
LTE_DL_FRAME_PARMS *get_lte_frame_parms(module_id_t Mod_id, uint8_t CC_id);

516
MU_MIMO_mode* get_mu_mimo_mode (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
517

518 519
int16_t get_hundred_times_delta_IF(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t harq_pid);

520
int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor);
521 522 523

int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid);

524 525
int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id);
int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id);
526

knopp's avatar
knopp committed
527
int get_ue_active_harq_pid(uint8_t Mod_id,uint8_t CC_id,uint16_t rnti,int frame, uint8_t subframe,uint8_t *harq_pid,uint8_t *round,uint8_t ul_flag);
528

529 530 531
void dump_dlsch(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid);
void dump_dlsch_SI(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe);
void dump_dlsch_ra(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe);
532

Cedric Roux's avatar
Cedric Roux committed
533
void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid);
534 535


536 537 538 539
int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx);

void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);

540
/*@}*/
541 542 543 544 545


#endif