sched_eNB.h 8.63 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
/*
  \author R. Knopp, F. Kaltenberger
  \company EURECOM
  \email knopp@eurecom.fr
*/

28 29
#ifndef __openair_SCHED_ENB_H__
#define __openair_SCHED_ENB_H__
30

31 32
#include "PHY/defs_eNB.h"
#include "PHY_INTERFACE/phy_interface.h"
33
#include "sched_common.h"
Raymond Knopp's avatar
 
Raymond Knopp committed
34

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


#define OPENAIR_THREAD_PRIORITY        255


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

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

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 {
69 70 71 72
  openair_NOT_SYNCHED=1,
  openair_SYNCHED,
  openair_SCHED_EXIT
};
73

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

#define DAQ_AGC_ON 1
#define DAQ_AGC_OFF 0


/** @addtogroup _PHY_PROCEDURES_
 * @{
 */


89 90

/*! \brief Scheduling for eNB TX procedures in normal subframes.
91 92
  @param phy_vars_eNB Pointer to eNB variables on which to act
  @param abstraction_flag Indicator of PHY abstraction
93
  @param do_meas Do inline timing measurement
94
*/
95
void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc,int do_meas);
96

97
/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes.
98
  @param phy_vars_eNB Pointer to eNB variables on which to act
99
  @param proc Pointer to RXn-TXnp4 proc information
100
*/
101
void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc);
102 103 104

/*! \brief Scheduling for eNB TX procedures in TDD S-subframes.
  @param phy_vars_eNB Pointer to eNB variables on which to act
105
  @param proc Pointer to RXn-TXnp4 proc information
106 107 108 109 110 111 112
  @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
*/
113
void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc);
114

115
/*! \brief Scheduling for eNB TX procedures in TDD S-subframes.
116 117
  @param phy_vars_eNB Pointer to eNB variables on which to act
*/
118

119
void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB);
120

121
/*! \brief Scheduling for eNB RX procedures in TDD S-subframes.
122 123
  @param phy_vars_eNB Pointer to eNB variables on which to act
*/
124
void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc);
125

126
/*! \brief Scheduling for eNB PRACH RX procedures
127
  @param phy_vars_eNB Pointer to eNB variables on which to act
128
  @param br_flag indicator for eMTC PRACH
129
*/
130
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
131 132 133 134
void prach_procedures(PHY_VARS_eNB *eNB,
		      int br_flag);
#else
void prach_procedures(PHY_VARS_eNB *eNB);
135
#endif
136

137
/*! \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).
138
  @param frame_parms Pointer to DL frame parameter descriptor
139
  @param current_subframe Index of subframe where RA_RNTI was received
140 141 142 143 144
  @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,
145 146 147 148
                    uint8_t current_subframe,
                    uint32_t current_frame,
                    uint32_t *frame,
                    uint8_t *subframe);
149

150
/*! \brief Function to compute timing of Msg3 retransmission on UL-SCH (first UE transmission in RA procedure).
151
  @param frame_parms Pointer to DL frame parameter descriptor
152
  @param current_subframe Index of subframe where RA_RNTI was received
153 154 155 156 157
  @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,
158 159 160 161
                        uint8_t current_subframe,
                        uint32_t current_frame,
                        uint32_t *frame,
                        uint8_t *subframe);
162

163
/*! \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
164 165 166 167 168
   @param frame_parms Pointer to DL Frame Parameters
   @param frame Frame index
   @param current_subframe subframe of RAR transmission
   @returns harq_pid (0 ... 7)
 */
169
uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe);
170

171
/*! \brief Get ULSCH harq_pid from PHICH subframe
172 173 174 175 176
   @param frame_parms Pointer to DL Frame Parameters
   @param subframe subframe of PHICH
   @returns harq_pid (0 ... 7)
 */

177
/*! \brief Function to indicate failure of contention resolution or RA procedure.  It places the UE back in PRACH mode.
178
    @param Mod_id Instance index of UE
Raymond Knopp's avatar
 
Raymond Knopp committed
179
    @param CC_id Component Carrier Index
180 181
    @param eNB_index Index of eNB
 */
Raymond Knopp's avatar
 
Raymond Knopp committed
182
void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
183

184
/*! \brief Indicates the SR TXOp in current subframe for eNB and particular UE index.  Implements Table 10.1-5 from 36.213.
185 186 187 188
  @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.
*/
189
uint8_t is_SR_subframe(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc,uint8_t UE_id);
190

191 192 193
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);

194 195


Raymond Knopp's avatar
Raymond Knopp committed
196

197

198 199
void schedule_response(Sched_Rsp_t *Sched_INFO);

200
LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti);
201

202 203 204 205 206 207 208
/*! \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.
  @param Mod_id Index of eNB
  @param CC_id Component Carrier Index
  @param subframe Subframe index
  @returns Subframe type (DL,UL,S)
*/
lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe);
Raymond Knopp's avatar
Raymond Knopp committed
209 210


211
int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint16_t UE_id,uint8_t harq_pid, uint8_t bw_factor);
212 213 214

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

215 216
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);
217

218 219 220 221
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);

222
/*@}*/
223 224 225 226 227


#endif