pusch_pc.c 5.19 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
/*! \file pusch_pc.c
23
 * \brief Implementation of UE PUSCH Power Control procedures from 36.213 LTE specifications (Section
24 25 26 27 28 29 30 31 32
 * \author R. Knopp
 * \date 2011
 * \version 0.1
 * \company Eurecom
 * \email: knopp@eurecom.fr
 * \note
 * \warning
 */

33 34 35 36 37
#include "sched_UE.h"
#include "SCHED/sched_common_extern.h"
#include "PHY/defs_UE.h"
#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
#include "PHY/phy_extern_ue.h"
38
#include "PHY/LTE_ESTIMATION/lte_estimation.h"
39

40 41
extern uint8_t  nfapi_mode;

42
int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid)
43 44
{

hbilel's avatar
hbilel committed
45
  uint32_t Nre = 2*ue->ulsch[eNB_id]->harq_processes[harq_pid]->Nsymb_initial *
46
                 ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb*12;
47 48 49 50

  if (Nre==0)
    return(0);

hbilel's avatar
hbilel committed
51
  uint32_t MPR_x100 = 100*ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/Nre;
52 53
  // Note: MPR=is the effective spectral efficiency of the PUSCH
  // FK 20140908 sumKr is only set after the ulsch_encoding
54

55 56
  uint16_t beta_offset_pusch = (ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ?
    ue->ulsch[eNB_id]->beta_offset_cqi_times8:8;
57

58
  if (ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled == 1) {
59 60
    // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch)
    return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3));
61
  } else {
62 63 64 65 66
    return(0);
  }
}


67

68
uint8_t alpha_lut[8] = {0,40,50,60,70,80,90,100};
69

70
void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag)
71 72
{

73

74
  uint8_t harq_pid = subframe2harq_pid(&ue->frame_parms,
75 76
                                       proc->frame_tx,
                                       proc->subframe_tx);
77

78
  uint8_t nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb;
79
  int16_t PL;
80 81


82
  // P_pusch = 10*log10(nb_rb + P_opusch(j)+ alpha(u)*PL + delta_TF(i) + f(i))
83
  //
84 85 86
  // P_opusch(0) = P_oPTR + deltaP_Msg3 if PUSCH is transporting Msg3
  // else
  // P_opusch(0) = PO_NOMINAL_PUSCH(j) + P_O_UE_PUSCH(j)
87
  PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id);
88

89 90 91
  ue->ulsch[eNB_id]->Po_PUSCH = (hundred_times_log10_NPRB[nb_rb-1]+
				 get_hundred_times_delta_IF(ue,eNB_id,harq_pid) +
				 100*ue->ulsch[eNB_id]->f_pusch)/100;
92

93
  if(ue->ulsch_Msg3_active[eNB_id] == 1) {  // Msg3 PUSCH
94

95
    ue->ulsch[eNB_id]->Po_PUSCH += (get_Po_NOMINAL_PUSCH(ue->Mod_id,0) + PL);
96 97


98
    LOG_I(PHY,"[UE  %d][RAPROC] frame %d, subframe %d: Msg3 Po_PUSCH %d dBm (%d,%d,100*PL=%d,%d,%d)\n",
99
          ue->Mod_id,proc->frame_tx,proc->subframe_tx,ue->ulsch[eNB_id]->Po_PUSCH,
100
          100*get_Po_NOMINAL_PUSCH(ue->Mod_id,0),
101 102
          hundred_times_log10_NPRB[nb_rb-1],
          100*PL,
103 104
          get_hundred_times_delta_IF(ue,eNB_id,harq_pid),
          100*ue->ulsch[eNB_id]->f_pusch);
105 106 107
  } else if (j==0) { // SPS PUSCH
  } else if (j==1) { // Normal PUSCH

108 109 110
    ue->ulsch[eNB_id]->Po_PUSCH +=  ((alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL)/100);
    ue->ulsch[eNB_id]->Po_PUSCH +=  ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH;
    ue->ulsch[eNB_id]->PHR       =  ue->tx_power_max_dBm-ue->ulsch[eNB_id]->Po_PUSCH;  
111

112 113 114 115
    if (ue->ulsch[eNB_id]->PHR < -23)
      ue->ulsch[eNB_id]->PHR = -23;
    else if (ue->ulsch[eNB_id]->PHR > 40)
      ue->ulsch[eNB_id]->PHR = 40;
116

117
    LOG_D(PHY,"[UE  %d][PUSCH %d] AbsSubframe %d.%d: nb_rb: %d, Po_PUSCH %d dBm : tx power max %d , Po_NOMINAL_PUSCH %d,log10(NPRB) %f,PHR %d, PL %d, alpha*PL %f,delta_IF %f,f_pusch %d\n",
hbilel's avatar
hbilel committed
118
          ue->Mod_id,harq_pid,proc->frame_tx,proc->subframe_tx,nb_rb,
119 120 121
          ue->ulsch[eNB_id]->Po_PUSCH,
          ue->tx_power_max_dBm,
          ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH,
122
          hundred_times_log10_NPRB[nb_rb-1]/100.0,
123
          ue->ulsch[eNB_id]->PHR,
124
          PL,
125 126 127
          alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL/100.0,
          get_hundred_times_delta_IF(ue,eNB_id,harq_pid)/100.0,
          ue->ulsch[eNB_id]->f_pusch);
128
  }
129

130 131
}

132 133
int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index)
{
134 135 136 137
	if(nfapi_mode!=3)
		return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR;
	else
		return 40; // For nfapi_mode=3 consider ideal conditions
138
}