pucch_pc.c 4.06 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
#include "PHY/defs_UE.h"
#include "SCHED_UE/sched_UE.h"
#include "SCHED/sched_common_extern.h"
#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
knopp's avatar
knopp committed
37
#include "PHY/LTE_ESTIMATION/lte_estimation.h"
38

Bilel's avatar
Bilel committed
39
int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt)
40
{
41

Bilel's avatar
Bilel committed
42
  int16_t Po_PUCCH;
43
  //uint8_t harq_pid;
44 45

  // P_pucch =  P_opucch+ PL + h(nCQI,nHARQ) + delta_pucchF(pucch_fmt) + g(i))
46
  //
47 48
  //if ((pucch_fmt == pucch_format1a) ||
  //    (pucch_fmt == pucch_format1b)) {  // Update g_pucch based on TPC/delta_PUCCH received in PDCCH for this process
49
    //harq_pid = ue->dlsch[eNB_id][0]->harq_ack[subframe].harq_id;
50
    //this is now done in dci_tools
51
    //ue->g_pucch[eNB_id] += ue->dlsch[eNB_id][0]->harq_processes[harq_pid]->delta_PUCCH;
52
  //}
53

54 55
  Po_PUCCH = get_PL(ue->Mod_id,ue->CC_id,eNB_id)+
    ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH+
56
    ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch;
57

58 59 60 61
  switch (pucch_fmt) {
  case pucch_format1:
  case pucch_format2a:
  case pucch_format2b:
62
    Po_PUCCH += (-2+(ue->frame_parms.ul_power_control_config_common.deltaF_PUCCH_Format1<<1));
63
    break;
64

65 66
  case pucch_format1a:
  case pucch_format1b:
67 68 69
  case pucch_format1b_csA2:
  case pucch_format1b_csA3:
  case pucch_format1b_csA4:
70
    Po_PUCCH += (1+(ue->frame_parms.ul_power_control_config_common.deltaF_PUCCH_Format1b<<1));
71
    break;
72

73
  case pucch_format2:
74
    switch (ue->frame_parms.ul_power_control_config_common.deltaF_PUCCH_Format2a) {
75 76 77
    case 0:
      Po_PUCCH -= 2;
      break;
78

79 80 81
    case 2:
      Po_PUCCH += 1;
      break;
82

83 84 85
    case 3:
      Po_PUCCH += 2;
      break;
86

87 88 89 90
    case 1:
    default:
      break;
    }
91

92
    break;
93 94 95 96

  case pucch_format3:
    fprintf(stderr, "PUCCH format 3 not handled\n");
    abort();
97
  }
98

99
  if (pucch_fmt!=pucch_format1) {
100
    LOG_D(PHY,"[UE  %d][PDSCH %x] AbsSubframe %d.%d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB, g_pucch %d dB\n",
101
          ue->Mod_id,
102
          ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti,proc->frame_tx%1024,subframe,
103
          Po_PUCCH,
104 105
          ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
          get_PL(ue->Mod_id,ue->CC_id,eNB_id),
106
          ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch);
107
  } else {
108
    LOG_D(PHY,"[UE  %d][SR %x] AbsSubframe %d.%d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB g_pucch %d dB\n",
109
          ue->Mod_id,
110
          ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti,proc->frame_tx%1024,subframe,
111
          Po_PUCCH,
112 113
          ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
          get_PL(ue->Mod_id,ue->CC_id,eNB_id),
114
          ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch);
115
  }
116

117 118
  return(Po_PUCCH);
}