lte_param_init.c 5.38 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 21
 * 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
 */

22 23 24 25 26 27
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <execinfo.h>
#include <signal.h>

28
#include "SIMULATION/TOOLS/sim.h"
29
#include "PHY/types.h"
30 31 32
#include "PHY/defs_eNB.h"
#include "PHY/defs_UE.h"
#include "PHY/phy_extern.h"
knopp's avatar
knopp committed
33 34 35
#include "phy_init.h"
#include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
36

37 38
extern PHY_VARS_eNB *eNB;
extern PHY_VARS_UE *UE;
knopp's avatar
knopp committed
39
extern RU_t *ru;
40
extern void  phy_init_RU(RU_t*);
41

knopp's avatar
knopp committed
42 43 44
void lte_param_init(PHY_VARS_eNB **eNBp,
		    PHY_VARS_UE **UEp,
		    RU_t **rup,
Cedric Roux's avatar
Cedric Roux committed
45
		    unsigned char N_tx_port_eNB,
46
                    unsigned char N_tx_phy,
47 48
		    unsigned char N_rx_ru,
                    unsigned char N_rx_ue,
49 50
		    unsigned char transmission_mode,
		    uint8_t extended_prefix_flag,
Cedric Roux's avatar
Cedric Roux committed
51
		    frame_t frame_type,
52 53 54
		    uint16_t Nid_cell,
		    uint8_t tdd_config,
		    uint8_t N_RB_DL,
knopp's avatar
knopp committed
55
		    uint8_t pa,
56 57 58 59 60
		    uint8_t threequarter_fs,
                    uint8_t osf,
		    uint32_t perfect_ce)
{

61
  LTE_DL_FRAME_PARMS *frame_parms;
62
  int i;
knopp's avatar
knopp committed
63 64 65
  PHY_VARS_eNB *eNB;
  PHY_VARS_UE  *UE;
  RU_t         *ru;
66
  printf("Start lte_param_init\n");
knopp's avatar
knopp committed
67 68 69 70 71 72 73 74 75 76
  *eNBp = malloc(sizeof(PHY_VARS_eNB));
  *UEp = malloc(sizeof(PHY_VARS_UE));
  *rup = malloc(sizeof(RU_t));
  eNB = *eNBp;
  UE  = *UEp;
  ru  = *rup;
  printf("eNB %p, UE %p, ru %p\n",eNB,UE,ru);



77 78
  memset((void*)eNB,0,sizeof(PHY_VARS_eNB));
  memset((void*)UE,0,sizeof(PHY_VARS_UE));
knopp's avatar
knopp committed
79
  memset((void*)ru,0,sizeof(RU_t));
80

knopp's avatar
knopp committed
81 82 83
  ru->eNB_list[0] = eNB;
  eNB->RU_list[0] = ru;
  ru->num_eNB=1;
84 85 86 87 88

  srand(0);
  randominit(0);
  set_taus_seed(0);

89
  frame_parms = &(eNB->frame_parms);
90

91 92 93 94 95 96 97
  frame_parms->N_RB_DL            = N_RB_DL;   //50 for 10MHz and 25 for 5 MHz
  frame_parms->N_RB_UL            = N_RB_DL;
  frame_parms->threequarter_fs    = threequarter_fs;
  frame_parms->Ncp                = extended_prefix_flag;
  frame_parms->Ncp_UL             = extended_prefix_flag;
  frame_parms->Nid_cell           = Nid_cell;
  frame_parms->nushift            = Nid_cell%6;
98
  frame_parms->nb_antennas_tx     = N_tx_phy;
99
  frame_parms->nb_antennas_rx     = N_rx_ru;
100
  frame_parms->nb_antenna_ports_eNB = N_tx_port_eNB;
101 102
  frame_parms->phich_config_common.phich_resource         = oneSixth;
  frame_parms->phich_config_common.phich_duration         = normal;
103 104 105 106 107 108
  frame_parms->tdd_config         = tdd_config;
  frame_parms->frame_type         = frame_type;
  //  frame_parms->Csrs = 2;
  //  frame_parms->Bsrs = 0;
  //  frame_parms->kTC = 0;44
  //  frame_parms->n_RRC = 0;
109

110
  init_frame_parms(frame_parms,osf);
111

112
  //copy_lte_parms_to_phy_framing(frame_parms, &(PHY_config->PHY_framing));
113

114
  //  phy_init_top(frame_parms); //allocation
115

116 117
  UE->is_secondary_ue = 0;
  UE->frame_parms = *frame_parms;
118
  UE->frame_parms.nb_antennas_rx=N_rx_ue;
knopp's avatar
knopp committed
119 120 121
  //  eNB->frame_parms = *frame_parms;
  ru->frame_parms = *frame_parms;
  ru->nb_tx = N_tx_phy;
122
  ru->nb_rx = N_rx_ru;
knopp's avatar
knopp committed
123 124 125
  ru->if_south = LOCAL_RF;

  eNB->configured=1;
126

127 128
  eNB->transmission_mode[0] = transmission_mode;
  UE->transmission_mode[0] = transmission_mode;
129

130
  dump_frame_parms(frame_parms);
131

132 133 134
  UE->measurements.n_adj_cells=0;
  UE->measurements.adj_cell_id[0] = Nid_cell+1;
  UE->measurements.adj_cell_id[1] = Nid_cell+2;
135 136

  for (i=0; i<3; i++)
137
    lte_gold(frame_parms,UE->lte_gold_table[i],Nid_cell+i);
138

knopp's avatar
knopp committed
139 140 141
  printf("Calling init_lte_ue_signal\n");
  init_lte_ue_signal(UE,1,0);
  printf("Calling phy_init_lte_eNB\n");
knopp's avatar
knopp committed
142
  phy_init_lte_eNB(eNB,0,0);
knopp's avatar
knopp committed
143 144
  printf("Calling phy_init_RU (%p)\n",ru);
  phy_init_RU(ru);
145 146
  generate_pcfich_reg_mapping(&UE->frame_parms);
  generate_phich_reg_mapping(&UE->frame_parms);
147 148

  // DL power control init
149
  //if (transmission_mode == 1) {
Cedric Roux's avatar
Cedric Roux committed
150
  UE->pdsch_config_dedicated->p_a  = pa;
knopp's avatar
knopp committed
151

152
  if (transmission_mode == 1 || transmission_mode ==7) {
153 154
    ((eNB->frame_parms).pdsch_config_common).p_b = 0;
    ((UE->frame_parms).pdsch_config_common).p_b = 0;
155
  } else { // rho_a = rhob
156 157
    ((eNB->frame_parms).pdsch_config_common).p_b = 1;
    ((UE->frame_parms).pdsch_config_common).p_b = 1;
158 159
  }

160
  UE->perfect_ce = perfect_ce;
161

162 163 164
  /* the UE code is multi-thread "aware", we need to setup this array */
  for (i = 0; i < 10; i++) UE->current_thread_id[i] = i % 2;

165 166 167 168
  if (eNB->frame_parms.frame_type == TDD) {
    if      (eNB->frame_parms.N_RB_DL == 100) ru->N_TA_offset = 624;
    else if (eNB->frame_parms.N_RB_DL == 50)  ru->N_TA_offset = 624/2;
    else if (eNB->frame_parms.N_RB_DL == 25)  ru->N_TA_offset = 624/4;
Cedric Roux's avatar
Cedric Roux committed
169
  }
170 171
  else ru->N_TA_offset=0;

172 173 174 175
  printf("Done lte_param_init\n");


}