power_control.c 5.33 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    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
17
18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19
20
21
22
23
   see <http://www.gnu.org/licenses/>.

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

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

 *******************************************************************************/
29
30
31
#include "PHY/defs.h"
#include "PHY/impl_defs_lte.h"

32
//#define DEBUG_PC 
33
34
35

/*
double ratioPB[2][4]={{ 1.0,4.0/5.0,3.0/5.0,2.0/5.0},
36
          { 5.0/4.0,1.0,3.0/4.0,1.0/2.0}};
37
38
*/
					  
39
double ratioPB[2][4]={{ 0.00000,  -0.96910,  -2.21849,  -3.97940}, //in db
40
41
		      { 0.96910,   0.00000,  -1.24939,  -3.01030}};

42
double pa_values[8]={-6.0,-4.77,-3.0,-1.77,0.0,1.0,2.0,3.0}; //reported by higher layers
43

44
45
double get_pa_dB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated)
{
46
  return(pa_values[pdsch_config_dedicated->p_a]);
47
}
48
49

double computeRhoA_eNB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,  
50
                       LTE_eNB_DLSCH_t *dlsch_eNB,int dl_power_off, uint8_t n_antenna_port){		    	
51
52
53
54
55
  double rho_a_dB;
  double sqrt_rho_a_lin;

  rho_a_dB = pa_values[ pdsch_config_dedicated->p_a];
	
56
  if(!dl_power_off) //if dl_power_offset is 0, this is for MU-interference, TM5
57
    rho_a_dB-=10*log10(2);
58
59
60
  
  if(n_antenna_port==4) // see TS 36.213 Section 5.2
    rho_a_dB=+10*log10(2);
61
62
63
64
	
  sqrt_rho_a_lin= pow(10,(0.05*rho_a_dB));	
	
  dlsch_eNB->sqrt_rho_a= (short) (sqrt_rho_a_lin*pow(2,13));
65

66
#if DEBUG_PC
67
  printf("eNB: p_a=%d, value=%f, sqrt_rho_a=%d\n",pdsch_config_dedicated->p_a,pa_values[ pdsch_config_dedicated->p_a],dlsch_eNB->sqrt_rho_a);
68
#endif
69
70

  return(rho_a_dB);
71
72
73
74
}

double computeRhoB_eNB(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
                       PDSCH_CONFIG_COMMON *pdsch_config_common,
gauthier's avatar
gauthier committed
75
                       uint8_t n_antenna_port,
76
                       LTE_eNB_DLSCH_t *dlsch_eNB,
77
78
                       int dl_power_off)
{
79
80
81
82

  double rho_a_dB, rho_b_dB;
  double sqrt_rho_b_lin;
	
83
  rho_a_dB= computeRhoA_eNB(pdsch_config_dedicated,dlsch_eNB,dl_power_off, n_antenna_port);
84
85
86
87
88
89
	
  if(n_antenna_port>1)
    rho_b_dB= ratioPB[1][pdsch_config_common->p_b] + rho_a_dB;
  else
    rho_b_dB= ratioPB[0][pdsch_config_common->p_b] + rho_a_dB;

90
91
  sqrt_rho_b_lin= pow(10,(0.05*rho_b_dB));

92
93
  dlsch_eNB->sqrt_rho_b= (short) (sqrt_rho_b_lin*pow(2,13));

94
#ifdef DEBUG_PC
95
  printf("eNB: n_ant=%d, p_b=%d -> rho_b/rho_a=%f -> sqrt_rho_b=%d\n",n_antenna_port,pdsch_config_common->p_b,ratioPB[1][pdsch_config_common->p_b],dlsch_eNB->sqrt_rho_b);
96
97
#endif
  return(rho_b_dB);
98
99
100
}


101
double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
102
                      LTE_UE_DLSCH_t *dlsch_ue,
103
104
105
                      unsigned char dl_power_off, 
		      uint8_t n_antenna_port
 		    ){		    	
106
107
108
109
110
111
112
    
  double rho_a_dB;
  double sqrt_rho_a_lin;

  rho_a_dB = pa_values[ pdsch_config_dedicated->p_a];
	
  if(!dl_power_off) 
113
114
115
116
117
    rho_a_dB-=10*log10(2); 
  //if dl_power_offset is 0, this is for MU-interference, TM5. But in practice UE may assume 16 or 64QAM TM4 as multiuser
  
   if(n_antenna_port==4) // see TS 36.213 Section 5.2
    rho_a_dB=+10*log10(2);
118
119
120
121
	
  sqrt_rho_a_lin= pow(10,(0.05*rho_a_dB));	
	
  dlsch_ue->sqrt_rho_a= (short) (sqrt_rho_a_lin*pow(2,13));
122
123

#ifdef DEBUG_PC
124
  printf("UE: p_a=%d, value=%f, dl_power_off=%d, sqrt_rho_a=%d\n",pdsch_config_dedicated->p_a,pa_values[ pdsch_config_dedicated->p_a],dl_power_off,dlsch_ue->sqrt_rho_a);
125
#endif
126
127

  return(rho_a_dB);
128
129
130
131
}

double computeRhoB_UE(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
                      PDSCH_CONFIG_COMMON *pdsch_config_common,
gauthier's avatar
gauthier committed
132
                      uint8_t n_antenna_port,
133
                      LTE_UE_DLSCH_t *dlsch_ue,
134
135
                      unsigned char dl_power_off)
{
136
137
138
139

  double rho_a_dB, rho_b_dB;
  double sqrt_rho_b_lin;
	
140
  rho_a_dB= computeRhoA_UE(pdsch_config_dedicated,dlsch_ue,dl_power_off, n_antenna_port);
141
142
143
144
145
146
	
  if(n_antenna_port>1)
    rho_b_dB= ratioPB[1][pdsch_config_common->p_b] + rho_a_dB;
  else
    rho_b_dB= ratioPB[0][pdsch_config_common->p_b] + rho_a_dB;

147
148
  sqrt_rho_b_lin= pow(10,(0.05*rho_b_dB));

149
150
  dlsch_ue->sqrt_rho_b= (short) (sqrt_rho_b_lin*pow(2,13));

151
#ifdef DEBUG_PC
152
  printf("UE: p_b=%d, n_ant=%d -> ratio=%f -> sqrt_rho_b=%d\n",pdsch_config_common->p_b, n_antenna_port,ratioPB[1][pdsch_config_common->p_b],dlsch_ue->sqrt_rho_b);
153
154
#endif
  return(rho_b_dB);
155
156
157
}