defs.h 14.8 KB
Newer Older
1
/*******************************************************************************
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

5 6 7 8
    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.
9 10


11 12 13 14
    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.
15

16 17 18 19
    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/>.
20 21

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

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27 28

*******************************************************************************/
29

30
/*! \file PHY_INTERFACE/defs.h
31
* \brief mac phy interface primitives
32 33 34
* \author Raymond Knopp and Navid Nikaein
* \date 2011
* \version 0.5
35
* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
*/

#ifndef __MAC_PHY_PRIMITIVES_H__
#    define __MAC_PHY_PRIMITIVES_H__


#include "LAYER2/MAC/defs.h"



#define MAX_NUMBER_OF_MAC_INSTANCES 16

#define NULL_PDU 255
#define DCI 0
#define DLSCH 1
#define ULSCH 2

53 54 55 56 57 58
#define mac_exit_wrapper(sTRING)                                                            \
do {                                                                                        \
    char temp[300];                                                                         \
    snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__);   \
    mac_xface->macphy_exit(temp);                                                           \
} while(0)
59

60 61 62 63
/** @defgroup _phy_if MAC-PHY interface
 * @ingroup _oai2
 * @{
 */
64
/*! \brief MACPHY Interface */
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
typedef struct {
  /// Pointer function that initializes L2
  int (*macphy_init)(int eMBMS_active, char *uecap_xer, uint8_t CBA_active,uint8_t HO_active);

  /// Pointer function that stops the low-level scheduler due an exit condition
  void (*macphy_exit)(const char *);

  // eNB functions
  /// Invoke dlsch/ulsch scheduling procedure for new subframe
  void (*eNB_dlsch_ulsch_scheduler)(module_id_t Mod_id,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP);//, int calibration_flag);

  /// Fill random access response sdu, passing timing advance
  uint16_t (*fill_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t N_RB_UL, uint8_t input_buffer_length);

  /// Initiate the RA procedure upon reception (hypothetical) of a valid preamble
  void (*initiate_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id);

  /// cancel an ongoing RA procedure
  void (*cancel_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble);

  /// Get DCI for current subframe from MAC
  DCI_PDU* (*get_dci_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe);

  /// Get DLSCH sdu for particular RNTI and Transport block index
  uint8_t* (*get_dlsch_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TB_index);

  /// Send ULSCH sdu to MAC for given rnti
92
  void (*rx_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP, sub_frame_t sub_frameP,rnti_t rnti, uint8_t *sdu,uint16_t sdu_len, int harq_pid,uint8_t *msg3_flag);
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

  /// Indicate failure to synch to external source
  void (*mrbch_phy_sync_failure) (module_id_t Mod_id,frame_t frameP, uint8_t free_eNB_index);

  /// Indicate Scheduling Request from UE
  void (*SR_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe);

  /// Configure Common PHY parameters from SIB1
  void (*phy_config_sib1_eNB)(module_id_t Mod_id,int CC_id,
                              TDD_Config_t *tdd_config,
                              uint8_t SIwindowsize,
                              uint16_t SIperiod);

  /// Configure Common PHY parameters from SIB2
  void (*phy_config_sib2_eNB)(module_id_t Mod_id, int CC_id,
                              RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
                              ARFCN_ValueEUTRA_t *ul_CArrierFreq,
                              long *ul_Bandwidth,
                              AdditionalSpectrumEmission_t *additionalSpectrumEmission,
                              struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList);

114
#ifdef Rel10
115 116 117 118 119 120 121 122
  /// Configure Common PHY parameters from SIB13
  void (*phy_config_sib13_eNB)(module_id_t Mod_id,int CC_id, int mbsfn_Area_idx,
                               long mbsfn_AreaId_r9);

  void (*phy_config_dedicated_scell_eNB)(uint8_t Mod_id,
                                         uint16_t rnti,
                                         SCellToAddMod_r10_t *sCellToAddMod_r10,
                                         int CC_id);
123
#endif
124 125 126 127

  /// PHY-Config-Dedicated eNB
  void (*phy_config_dedicated_eNB)(module_id_t Mod_id,int CC_id,rnti_t rnti,
                                   struct PhysicalConfigDedicated *physicalConfigDedicated);
128 129

#ifdef Rel10
130 131
  /// Get MCH sdu and corresponding MCS for particular MBSFN subframe
  MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, int CC_id, frame_t frameP,sub_frame_t subframe);
132
#endif
133 134 135 136
  // configure the cba rnti at the physical layer
  void (*phy_config_cba_rnti)(module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups);
  /// get delta mcs for fast UL AMC
  int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
137

138

139
  /// UE functions
140

141 142
  /// reset the ue phy
  void (*phy_reset_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
143

144 145 146 147 148 149 150 151
  /// Indicate loss of synchronization of PBCH for this eNB to MAC layer
  void (*out_of_sync_ind)(module_id_t Mod_id,frame_t frameP,uint16_t eNB_index);

  ///  Send a received SI sdu
  void (*ue_decode_si)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len);

  /// Send a received DLSCH sdu to MAC
  void (*ue_send_sdu)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t CH_index);
152 153

#ifdef Rel10
154 155
  /// Send a received MCH sdu to MAC
  void (*ue_send_mch_sdu)(module_id_t Mod_id,uint8_t CC_id, frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index,uint8_t sync_area);
156

157 158 159
  /// Function to check if UE PHY needs to decode MCH for MAC
  /// get the sync area id, and return MCS value if need to decode, otherwise -1
  int (*ue_query_mch)(module_id_t Mod_id, uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active);
160 161 162
#endif

  /// Retrieve ULSCH sdu from MAC
163
  void (*ue_get_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe, uint8_t CH_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode);
164

165 166
  /// Retrieve RRCConnectionReq from MAC
  PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe);
167

168 169
  /// Process Random-Access Response
  uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t *t_crnti,uint8_t preamble_index);
170

171 172
  /// Get SR payload (0,1) from UE MAC
  uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe);
173

174 175
  /// Indicate synchronization with valid PBCH
  void (*dl_phy_sync_success) (module_id_t Mod_id,frame_t frameP, uint8_t CH_index,uint8_t first_sync);
176

177 178
  /// Only calls the PDCP for now
  UE_L2_STATE_t (*ue_scheduler)(module_id_t Mod_id, frame_t frameP,sub_frame_t subframe, lte_subframe_t direction, uint8_t eNB_id, int CC_id);
179

180 181 182
  /// PHY-Config-Dedicated UE
  void (*phy_config_dedicated_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
                                  struct PhysicalConfigDedicated *physicalConfigDedicated);
183

184 185 186 187 188 189 190 191 192 193 194 195 196
  /// Configure Common PHY parameters from SIB1
  void (*phy_config_sib1_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
                             TDD_Config_t *tdd_config,
                             uint8_t SIwindowsize,
                             uint16_t SIperiod);

  /// Configure Common PHY parameters from SIB2
  void (*phy_config_sib2_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
                             RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
                             ARFCN_ValueEUTRA_t *ul_CArrierFreq,
                             long *ul_Bandwidth,
                             AdditionalSpectrumEmission_t *additionalSpectrumEmission,
                             struct MBSFN_SubframeConfigList  *mbsfn_SubframeConfigList);
197 198

#ifdef Rel10
199 200 201 202 203 204 205 206
  /// Configure Common PHY parameters from SIB13
  void (*phy_config_sib13_ue)(uint8_t Mod_id,int CC_id, uint8_t eNB_index,int mbsfn_Area_idx,
                              long mbsfn_AreaId_r9);

  void (*phy_config_dedicated_scell_ue)(uint8_t Mod_id,
                                        uint8_t eNB_index,
                                        SCellToAddMod_r10_t *sCellToAddMod_r10,
                                        int CC_id);
207
#endif
208 209 210 211 212 213 214
  /// Configure Common PHY parameters from mobilityControlInfo
  void (*phy_config_afterHO_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t CH_index,
                                MobilityControlInfo_t *mobilityControlInfo,
                                uint8_t ho_failed);

  /// Function to indicate failure of contention resolution or RA procedure
  void (*ra_failed)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
215

216 217
  /// Function to indicate success of contention resolution or RA procedure
  void (*ra_succeeded)(module_id_t Mod_id,uint8_t CC_id, uint8_t eNB_index);
218

219 220
  /// Function to indicate the transmission of msg1/rach to MAC
  void (*Msg1_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
221

222 223
  /// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer
  void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
224

225 226
  /// Function to pass inter-cell measurement parameters to PHY (cell Ids)
  void (*phy_config_meas_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,uint32_t *adj_cell_id);
227

228
  // PHY Helper Functions
229

230 231
  /// RIV computation from PHY
  uint16_t (*computeRIV)(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
232

233 234
  /// Downlink TBS table lookup from PHY
  uint32_t (*get_TBS_DL)(uint8_t mcs, uint16_t nb_rb);
235

236 237
  /// Uplink TBS table lookup from PHY
  uint32_t (*get_TBS_UL)(uint8_t mcs, uint16_t nb_rb);
238

239 240
  /// Function to retrieve the HARQ round index for a particular UL/DLSCH and harq_pid
  int (*get_ue_active_harq_pid)(module_id_t Mod_id, uint8_t CC_id,rnti_t rnti, int frame, uint8_t subframe, uint8_t *harq_pid, uint8_t *round, uint8_t ul_flag);
241

242 243
  /// Function to retrieve number of CCE
  uint16_t (*get_nCCE_max)(module_id_t Mod_id,uint8_t  CC_id);
244

245 246
  /// Function to get the CCE offset
  int (*get_nCCE_offset)(unsigned char L, int nCCE, int common_dci, unsigned short rnti, unsigned char subframe);
247

248 249
  /// Function to retrieve number of PRB in an rb_alloc
  uint32_t (*get_nb_rb)(uint8_t ra_header, uint32_t rb_alloc, int n_rb_dl);
250

251 252
  /// Function to retrieve transmission mode for UE
  uint8_t (*get_transmission_mode)(module_id_t Mod_id,uint8_t CC_id,rnti_t rnti);
253

254 255
  /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type
  uint32_t (*get_rballoc)(uint8_t vrb_type, uint16_t rb_alloc_dci);
256

257 258
  /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH)
  UE_MODE_t (*get_ue_mode)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
259

260 261
  /// Function for UE MAC to retrieve measured Path Loss
  int16_t (*get_PL)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
262

263 264
  /// Function for UE MAC to retrieve the rssi
  uint32_t (*get_RSSI)(uint8_t Mod_id,uint8_t CC_id);
265

266 267
  /// Function for UE MAC to retrieve the total gain
  uint32_t (*get_rx_total_gain_dB)(uint8_t Mod_id,uint8_t CC_id);
268

269 270
  /// Function for UE MAC to retrieve the number of adjustent cells
  uint8_t (*get_n_adj_cells)(uint8_t Mod_id,uint8_t CC_id);
271

272 273
  /// Function for UE MAC to retrieve RSRP/RSRQ measurements
  uint32_t (*get_RSRP)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
274

275 276
  /// Function for UE MAC to retrieve RSRP/RSRQ measurements
  uint32_t (*get_RSRQ)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
277

278 279
  /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements
  uint8_t (*set_RSRP_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp);
280

281 282
  /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements
  uint8_t (*set_RSRQ_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp);
283

284 285
  /// Function for UE/eNB MAC to retrieve number of PRACH in TDD
  uint8_t (*get_num_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms);
286

287 288
  /// Function for UE/eNB MAC to retrieve f_id of particular PRACH resource in TDD
  uint8_t (*get_fid_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms,uint8_t tdd_map_index);
289

290 291
  /// Function for eNB MAC to retrieve subframe direction
  lte_subframe_t (*get_subframe_direction)(module_id_t Mod_id, uint8_t CC_id, uint8_t subframe);
292

293 294 295
  // MAC Helper functions
  /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (Po_NOMINAL_PUSCH parameter)
  int8_t (*get_Po_NOMINAL_PUSCH)(module_id_t Mod_id,uint8_t  CC_id);
296

297 298
  /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (deltaP_rampup parameter)
  int8_t (*get_deltaP_rampup)(module_id_t Mod_id,uint8_t CC_id);
299

300 301
  /// Function for UE/PHY to compute PHR
  int8_t (*get_PHR)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
302

303
  void (*process_timing_advance)(module_id_t Mod_id,uint8_t CC_id, int16_t timing_advance);
304

305
  LTE_eNB_UE_stats* (*get_eNB_UE_stats)(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
306

307
  LTE_DL_FRAME_PARMS* (*get_lte_frame_parms)(module_id_t Mod_id, uint8_t CC_id);
308

309
  MU_MIMO_mode* (*get_mu_mimo_mode) (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
310

311
  int16_t (*get_hundred_times_delta_TF) (module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid);
312

313
  int16_t (*get_target_ul_rx_power) (module_id_t module_idP, uint8_t CC_id);
314

315 316 317 318
  unsigned char is_cluster_head;
  unsigned char is_primary_cluster_head;
  unsigned char is_secondary_cluster_head;
  unsigned char cluster_head_index;
319

320 321
  /// PHY Frame Configuration
  LTE_DL_FRAME_PARMS *lte_frame_parms;
322

323 324
  //ICIC algos
  uint8_t (*get_SB_size)(uint8_t n_rb_dl);
325

326
  //end ALU's algo
327

328
} MAC_xface;
329 330 331 332 333


#endif


334
/** @} */