print_stats.c 44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * 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
/*! \file PHY/LTE_TRANSPORT/print_stats.c
* \brief PHY statstic logging function
24
* \author R. Knopp, F. Kaltenberger, navid nikaein
25 26 27
* \date 2011
* \version 0.1
* \company Eurecom
28
* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
29 30 31 32 33 34 35 36 37 38
* \note
* \warning
*/

#include "PHY/LTE_TRANSPORT/proto.h"

#include "PHY/defs.h"
#include "PHY/extern.h"
#include "SCHED/extern.h"

39 40
#ifdef OPENAIR2
#include "../openair2/LAYER2/MAC/proto.h"
41
#include "../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
42
#endif
43 44

extern int mac_get_rrc_status(uint8_t Mod_id,uint8_t eNB_flag,uint8_t index);
45
#if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
46 47
#include "common_lib.h"
extern openair0_config_t openair0_cfg[];
48 49
#endif

50
int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length, runmode_t mode, int input_level_dBm)
51
{
52

53 54
  uint8_t eNB=0;
  uint32_t RRC_status;
55
  int len=length;
56
  int harq_pid,round;
57

58
  if (ue==NULL)
59 60 61
    return 0;

  if ((mode == normal_txrx) || (mode == no_L2_connect)) {
Bilel's avatar
Bilel committed
62
    len += sprintf(&buffer[len], "[UE_PROC] UE %d, RNTI %x\n",ue->Mod_id, ue->pdcch_vars[0][0]->crnti);
63
     len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %.2f dBm/RE, RSSI %.2f dBm, RSRQ[0] %.2f dB, N0 %d dBm/RE (NF %.1f dB)\n",
64 65 66 67 68
		    10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB,
		    10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, 
		    10*log10(ue->measurements.rsrq[0]),
		    ue->measurements.n0_power_tot_dBm,
		    (double)ue->measurements.n0_power_tot_dBm+132.24);
69 70

    /*
71
    len += sprintf(&buffer[len],
72
                   "[UE PROC] Frame count: %d\neNB0 RSSI %d dBm/RE (%d dB, %d dB)\neNB1 RSSI %d dBm/RE (%d dB, %d dB)neNB2 RSSI %d dBm/RE (%d dB, %d dB)\nN0 %d dBm/RE, %f dBm/%dPRB (%d dB, %d dB)\n",
73
                   proc->frame_rx,
74 75 76 77 78 79 80 81 82 83 84 85 86 87
                   ue->measurements.rx_rssi_dBm[0],
                   ue->measurements.rx_power_dB[0][0],
                   ue->measurements.rx_power_dB[0][1],
                   ue->measurements.rx_rssi_dBm[1],
                   ue->measurements.rx_power_dB[1][0],
                   ue->measurements.rx_power_dB[1][1],
                   ue->measurements.rx_rssi_dBm[2],
                   ue->measurements.rx_power_dB[2][0],
                   ue->measurements.rx_power_dB[2][1],
                   ue->measurements.n0_power_tot_dBm,
                   ue->measurements.n0_power_tot_dBm+10*log10(12*ue->frame_parms.N_RB_DL),
                   ue->frame_parms.N_RB_DL,
                   ue->measurements.n0_power_dB[0],
                   ue->measurements.n0_power_dB[1]);
88 89
    */

90
#ifdef EXMIMO
91
    len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",ue->rx_total_gain_dB, openair0_cfg[0].rxg_mode[0],(int)openair0_cfg[0].rx_gain[0]);
92
#endif
93
#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
94
    len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB\n",ue->rx_total_gain_dB);
95
#endif
96
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
97
    len += sprintf(&buffer[len], "[UE_PROC] Frequency offset %d Hz, estimated carrier frequency %f Hz\n",ue->common_vars.freq_offset,openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset);
98
#endif
99 100 101
    len += sprintf(&buffer[len], "[UE PROC] UE mode = %s (%d)\n",mode_string[ue->UE_mode[0]],ue->UE_mode[0]);
    len += sprintf(&buffer[len], "[UE PROC] timing_advance = %d\n",ue->timing_advance);
    if (ue->UE_mode[0]==PUSCH) {
102
      len += sprintf(&buffer[len], "[UE PROC] Po_PUSCH = %d dBm (PL %d dB, Po_NOMINAL_PUSCH %d dBm, PHR %d dB)\n", 
103 104 105 106
		     ue->ulsch[0]->Po_PUSCH,
		     get_PL(ue->Mod_id,ue->CC_id,0),
		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH,
		     ue->ulsch[0]->PHR);
107
      len += sprintf(&buffer[len], "[UE PROC] Po_PUCCH = %d dBm (Po_NOMINAL_PUCCH %d dBm, g_pucch %d dB)\n", 
108 109
		     get_PL(ue->Mod_id,ue->CC_id,0)+
		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH+
Bilel's avatar
Bilel committed
110
		     ue->dlsch[0][0][0]->g_pucch,
111
		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
Bilel's avatar
Bilel committed
112
		     ue->dlsch[0][0][0]->g_pucch);
113
    }
114 115 116 117
    //for (eNB=0;eNB<NUMBER_OF_eNB_MAX;eNB++) {
    for (eNB=0; eNB<1; eNB++) {
      len += sprintf(&buffer[len], "[UE PROC] RX spatial power eNB%d: [%d %d; %d %d] dB\n",
                     eNB,
118 119 120 121 122 123 124 125 126 127 128 129
                     ue->measurements.rx_spatial_power_dB[eNB][0][0],
                     ue->measurements.rx_spatial_power_dB[eNB][0][1],
                     ue->measurements.rx_spatial_power_dB[eNB][1][0],
                     ue->measurements.rx_spatial_power_dB[eNB][1][1]);

      len += sprintf(&buffer[len], "[UE PROC] RX total power eNB%d: %d dB, avg: %d dB\n",eNB,ue->measurements.rx_power_tot_dB[eNB],ue->measurements.rx_power_avg_dB[eNB]);
      len += sprintf(&buffer[len], "[UE PROC] RX total power lin: %d, avg: %d, RX total noise lin: %d, avg: %d\n",ue->measurements.rx_power_tot[eNB],
                     ue->measurements.rx_power_avg[eNB], ue->measurements.n0_power_tot, ue->measurements.n0_power_avg);
      len += sprintf(&buffer[len], "[UE PROC] effective SINR %.2f dB\n",ue->sinr_eff);
      len += sprintf(&buffer[len], "[UE PROC] Wideband CQI eNB %d: %d dB, avg: %d dB\n",eNB,ue->measurements.wideband_cqi_tot[eNB],ue->measurements.wideband_cqi_avg[eNB]);

      switch (ue->frame_parms.N_RB_DL) {
130 131 132
      case 6:
        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d] dB\n",
                       eNB,
133 134 135 136 137 138
                       ue->measurements.subband_cqi_dB[eNB][0][0],
                       ue->measurements.subband_cqi_dB[eNB][0][1],
                       ue->measurements.subband_cqi_dB[eNB][0][2],
                       ue->measurements.subband_cqi_dB[eNB][0][3],
                       ue->measurements.subband_cqi_dB[eNB][0][4],
                       ue->measurements.subband_cqi_dB[eNB][0][5]);
139 140 141 142


        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d] dB\n",
                       eNB,
143 144 145 146 147 148
                       ue->measurements.subband_cqi_dB[eNB][1][0],
                       ue->measurements.subband_cqi_dB[eNB][1][1],
                       ue->measurements.subband_cqi_dB[eNB][1][2],
                       ue->measurements.subband_cqi_dB[eNB][1][3],
                       ue->measurements.subband_cqi_dB[eNB][1][4],
                       ue->measurements.subband_cqi_dB[eNB][1][5]);
149 150 151 152


        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
153 154 155 156 157 158 159 160 161 162 163 164
                       ue->measurements.subband_pmi_re[eNB][0][0],
                       ue->measurements.subband_pmi_im[eNB][0][0],
                       ue->measurements.subband_pmi_re[eNB][1][0],
                       ue->measurements.subband_pmi_im[eNB][1][0],
                       ue->measurements.subband_pmi_re[eNB][2][0],
                       ue->measurements.subband_pmi_im[eNB][2][0],
                       ue->measurements.subband_pmi_re[eNB][3][0],
                       ue->measurements.subband_pmi_im[eNB][3][0],
                       ue->measurements.subband_pmi_re[eNB][4][0],
                       ue->measurements.subband_pmi_im[eNB][4][0],
                       ue->measurements.subband_pmi_re[eNB][5][0],
                       ue->measurements.subband_pmi_im[eNB][5][0]);
165 166 167

        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
168 169 170 171 172 173 174 175 176 177 178 179
                       ue->measurements.subband_pmi_re[eNB][0][1],
                       ue->measurements.subband_pmi_im[eNB][0][1],
                       ue->measurements.subband_pmi_re[eNB][1][1],
                       ue->measurements.subband_pmi_im[eNB][1][1],
                       ue->measurements.subband_pmi_re[eNB][2][1],
                       ue->measurements.subband_pmi_im[eNB][2][1],
                       ue->measurements.subband_pmi_re[eNB][3][1],
                       ue->measurements.subband_pmi_im[eNB][3][1],
                       ue->measurements.subband_pmi_re[eNB][4][1],
                       ue->measurements.subband_pmi_im[eNB][4][1],
                       ue->measurements.subband_pmi_re[eNB][5][1],
                       ue->measurements.subband_pmi_im[eNB][5][1]);
180 181 182

        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d]\n",
                       eNB,
183 184 185 186 187 188 189 190
                       ue->measurements.selected_rx_antennas[eNB][0],
                       ue->measurements.selected_rx_antennas[eNB][1],
                       ue->measurements.selected_rx_antennas[eNB][2],
                       ue->measurements.selected_rx_antennas[eNB][3],
                       ue->measurements.selected_rx_antennas[eNB][4],
                       ue->measurements.selected_rx_antennas[eNB][5]);

        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,6)));
191
        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
192 193
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,6)),
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,6)));
194 195 196 197 198
        break;

      case 25:
        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d] dB\n",
                       eNB,
199 200 201 202 203 204 205
                       ue->measurements.subband_cqi_dB[eNB][0][0],
                       ue->measurements.subband_cqi_dB[eNB][0][1],
                       ue->measurements.subband_cqi_dB[eNB][0][2],
                       ue->measurements.subband_cqi_dB[eNB][0][3],
                       ue->measurements.subband_cqi_dB[eNB][0][4],
                       ue->measurements.subband_cqi_dB[eNB][0][5],
                       ue->measurements.subband_cqi_dB[eNB][0][6]);
206 207 208

        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d] dB\n",
                       eNB,
209 210 211 212 213 214 215
                       ue->measurements.subband_cqi_dB[eNB][1][0],
                       ue->measurements.subband_cqi_dB[eNB][1][1],
                       ue->measurements.subband_cqi_dB[eNB][1][2],
                       ue->measurements.subband_cqi_dB[eNB][1][3],
                       ue->measurements.subband_cqi_dB[eNB][1][4],
                       ue->measurements.subband_cqi_dB[eNB][1][5],
                       ue->measurements.subband_cqi_dB[eNB][1][6]);
216 217 218 219


        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
220 221 222 223 224 225 226 227 228 229 230 231 232 233
                       ue->measurements.subband_pmi_re[eNB][0][0],
                       ue->measurements.subband_pmi_im[eNB][0][0],
                       ue->measurements.subband_pmi_re[eNB][1][0],
                       ue->measurements.subband_pmi_im[eNB][1][0],
                       ue->measurements.subband_pmi_re[eNB][2][0],
                       ue->measurements.subband_pmi_im[eNB][2][0],
                       ue->measurements.subband_pmi_re[eNB][3][0],
                       ue->measurements.subband_pmi_im[eNB][3][0],
                       ue->measurements.subband_pmi_re[eNB][4][0],
                       ue->measurements.subband_pmi_im[eNB][4][0],
                       ue->measurements.subband_pmi_re[eNB][5][0],
                       ue->measurements.subband_pmi_im[eNB][5][0],
                       ue->measurements.subband_pmi_re[eNB][6][0],
                       ue->measurements.subband_pmi_im[eNB][6][0]);
234 235 236

        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
237 238 239 240 241 242 243 244 245 246 247 248 249 250
                       ue->measurements.subband_pmi_re[eNB][0][1],
                       ue->measurements.subband_pmi_im[eNB][0][1],
                       ue->measurements.subband_pmi_re[eNB][1][1],
                       ue->measurements.subband_pmi_im[eNB][1][1],
                       ue->measurements.subband_pmi_re[eNB][2][1],
                       ue->measurements.subband_pmi_im[eNB][2][1],
                       ue->measurements.subband_pmi_re[eNB][3][1],
                       ue->measurements.subband_pmi_im[eNB][3][1],
                       ue->measurements.subband_pmi_re[eNB][4][1],
                       ue->measurements.subband_pmi_im[eNB][4][1],
                       ue->measurements.subband_pmi_re[eNB][5][1],
                       ue->measurements.subband_pmi_im[eNB][5][1],
                       ue->measurements.subband_pmi_re[eNB][6][1],
                       ue->measurements.subband_pmi_im[eNB][6][1]);
251 252 253

        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d]\n",
                       eNB,
254 255 256 257 258 259 260 261 262
                       ue->measurements.selected_rx_antennas[eNB][0],
                       ue->measurements.selected_rx_antennas[eNB][1],
                       ue->measurements.selected_rx_antennas[eNB][2],
                       ue->measurements.selected_rx_antennas[eNB][3],
                       ue->measurements.selected_rx_antennas[eNB][4],
                       ue->measurements.selected_rx_antennas[eNB][5],
                       ue->measurements.selected_rx_antennas[eNB][6]);

        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,7)));
263
        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
264 265
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,7)),
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,7)));
266 267 268 269 270
        break;

      case 50:
        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d] dB\n",
                       eNB,
271 272 273 274 275 276 277 278 279
                       ue->measurements.subband_cqi_dB[eNB][0][0],
                       ue->measurements.subband_cqi_dB[eNB][0][1],
                       ue->measurements.subband_cqi_dB[eNB][0][2],
                       ue->measurements.subband_cqi_dB[eNB][0][3],
                       ue->measurements.subband_cqi_dB[eNB][0][4],
                       ue->measurements.subband_cqi_dB[eNB][0][5],
                       ue->measurements.subband_cqi_dB[eNB][0][6],
                       ue->measurements.subband_cqi_dB[eNB][0][7],
                       ue->measurements.subband_cqi_dB[eNB][0][8]);
280 281 282

        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d] dB\n",
                       eNB,
283 284 285 286 287 288 289 290 291
                       ue->measurements.subband_cqi_dB[eNB][1][0],
                       ue->measurements.subband_cqi_dB[eNB][1][1],
                       ue->measurements.subband_cqi_dB[eNB][1][2],
                       ue->measurements.subband_cqi_dB[eNB][1][3],
                       ue->measurements.subband_cqi_dB[eNB][1][4],
                       ue->measurements.subband_cqi_dB[eNB][1][5],
                       ue->measurements.subband_cqi_dB[eNB][1][6],
                       ue->measurements.subband_cqi_dB[eNB][1][7],
                       ue->measurements.subband_cqi_dB[eNB][1][8]);
292 293 294 295


        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
                       ue->measurements.subband_pmi_re[eNB][0][0],
                       ue->measurements.subband_pmi_im[eNB][0][0],
                       ue->measurements.subband_pmi_re[eNB][1][0],
                       ue->measurements.subband_pmi_im[eNB][1][0],
                       ue->measurements.subband_pmi_re[eNB][2][0],
                       ue->measurements.subband_pmi_im[eNB][2][0],
                       ue->measurements.subband_pmi_re[eNB][3][0],
                       ue->measurements.subband_pmi_im[eNB][3][0],
                       ue->measurements.subband_pmi_re[eNB][4][0],
                       ue->measurements.subband_pmi_im[eNB][4][0],
                       ue->measurements.subband_pmi_re[eNB][5][0],
                       ue->measurements.subband_pmi_im[eNB][5][0],
                       ue->measurements.subband_pmi_re[eNB][6][0],
                       ue->measurements.subband_pmi_im[eNB][6][0],
                       ue->measurements.subband_pmi_re[eNB][7][0],
                       ue->measurements.subband_pmi_im[eNB][7][0],
                       ue->measurements.subband_pmi_re[eNB][8][0],
                       ue->measurements.subband_pmi_im[eNB][8][0]);
314 315 316

        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
                       ue->measurements.subband_pmi_re[eNB][0][1],
                       ue->measurements.subband_pmi_im[eNB][0][1],
                       ue->measurements.subband_pmi_re[eNB][1][1],
                       ue->measurements.subband_pmi_im[eNB][1][1],
                       ue->measurements.subband_pmi_re[eNB][2][1],
                       ue->measurements.subband_pmi_im[eNB][2][1],
                       ue->measurements.subband_pmi_re[eNB][3][1],
                       ue->measurements.subband_pmi_im[eNB][3][1],
                       ue->measurements.subband_pmi_re[eNB][4][1],
                       ue->measurements.subband_pmi_im[eNB][4][1],
                       ue->measurements.subband_pmi_re[eNB][5][1],
                       ue->measurements.subband_pmi_im[eNB][5][1],
                       ue->measurements.subband_pmi_re[eNB][6][1],
                       ue->measurements.subband_pmi_im[eNB][6][1],
                       ue->measurements.subband_pmi_re[eNB][7][1],
                       ue->measurements.subband_pmi_im[eNB][7][1],
                       ue->measurements.subband_pmi_re[eNB][8][1],
                       ue->measurements.subband_pmi_im[eNB][8][1]);
335 336 337

        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d]\n",
                       eNB,
338 339 340 341 342 343 344 345 346 347 348
                       ue->measurements.selected_rx_antennas[eNB][0],
                       ue->measurements.selected_rx_antennas[eNB][1],
                       ue->measurements.selected_rx_antennas[eNB][2],
                       ue->measurements.selected_rx_antennas[eNB][3],
                       ue->measurements.selected_rx_antennas[eNB][4],
                       ue->measurements.selected_rx_antennas[eNB][5],
                       ue->measurements.selected_rx_antennas[eNB][6],
                       ue->measurements.selected_rx_antennas[eNB][7],
                       ue->measurements.selected_rx_antennas[eNB][8]);

        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,9)));
349
        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
350 351
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,9)),
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,9)));
352 353 354 355 356
        break;

      case 100:
        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n",
                       eNB,
357 358 359 360 361 362 363 364 365 366 367 368 369
                       ue->measurements.subband_cqi_dB[eNB][0][0],
                       ue->measurements.subband_cqi_dB[eNB][0][1],
                       ue->measurements.subband_cqi_dB[eNB][0][2],
                       ue->measurements.subband_cqi_dB[eNB][0][3],
                       ue->measurements.subband_cqi_dB[eNB][0][4],
                       ue->measurements.subband_cqi_dB[eNB][0][5],
                       ue->measurements.subband_cqi_dB[eNB][0][6],
                       ue->measurements.subband_cqi_dB[eNB][0][7],
                       ue->measurements.subband_cqi_dB[eNB][0][8],
                       ue->measurements.subband_cqi_dB[eNB][0][9],
                       ue->measurements.subband_cqi_dB[eNB][0][10],
                       ue->measurements.subband_cqi_dB[eNB][0][11],
                       ue->measurements.subband_cqi_dB[eNB][0][12]);
370 371 372

        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n",
                       eNB,
373 374 375 376 377 378 379 380 381 382 383 384 385
                       ue->measurements.subband_cqi_dB[eNB][1][0],
                       ue->measurements.subband_cqi_dB[eNB][1][1],
                       ue->measurements.subband_cqi_dB[eNB][1][2],
                       ue->measurements.subband_cqi_dB[eNB][1][3],
                       ue->measurements.subband_cqi_dB[eNB][1][4],
                       ue->measurements.subband_cqi_dB[eNB][1][5],
                       ue->measurements.subband_cqi_dB[eNB][1][6],
                       ue->measurements.subband_cqi_dB[eNB][1][7],
                       ue->measurements.subband_cqi_dB[eNB][1][8],
                       ue->measurements.subband_cqi_dB[eNB][1][9],
                       ue->measurements.subband_cqi_dB[eNB][1][10],
                       ue->measurements.subband_cqi_dB[eNB][1][11],
                       ue->measurements.subband_cqi_dB[eNB][1][12]);
386 387 388 389


        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
                       ue->measurements.subband_pmi_re[eNB][0][0],
                       ue->measurements.subband_pmi_im[eNB][0][0],
                       ue->measurements.subband_pmi_re[eNB][1][0],
                       ue->measurements.subband_pmi_im[eNB][1][0],
                       ue->measurements.subband_pmi_re[eNB][2][0],
                       ue->measurements.subband_pmi_im[eNB][2][0],
                       ue->measurements.subband_pmi_re[eNB][3][0],
                       ue->measurements.subband_pmi_im[eNB][3][0],
                       ue->measurements.subband_pmi_re[eNB][4][0],
                       ue->measurements.subband_pmi_im[eNB][4][0],
                       ue->measurements.subband_pmi_re[eNB][5][0],
                       ue->measurements.subband_pmi_im[eNB][5][0],
                       ue->measurements.subband_pmi_re[eNB][6][0],
                       ue->measurements.subband_pmi_im[eNB][6][0],
                       ue->measurements.subband_pmi_re[eNB][7][0],
                       ue->measurements.subband_pmi_im[eNB][7][0],
                       ue->measurements.subband_pmi_re[eNB][8][0],
                       ue->measurements.subband_pmi_im[eNB][8][0],
                       ue->measurements.subband_pmi_re[eNB][9][0],
                       ue->measurements.subband_pmi_im[eNB][9][0],
                       ue->measurements.subband_pmi_re[eNB][10][0],
                       ue->measurements.subband_pmi_im[eNB][10][0],
                       ue->measurements.subband_pmi_re[eNB][11][0],
                       ue->measurements.subband_pmi_im[eNB][11][0],
                       ue->measurements.subband_pmi_re[eNB][12][0],
                       ue->measurements.subband_pmi_im[eNB][12][0]);
416 417 418

        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
                       eNB,
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
                       ue->measurements.subband_pmi_re[eNB][0][1],
                       ue->measurements.subband_pmi_im[eNB][0][1],
                       ue->measurements.subband_pmi_re[eNB][1][1],
                       ue->measurements.subband_pmi_im[eNB][1][1],
                       ue->measurements.subband_pmi_re[eNB][2][1],
                       ue->measurements.subband_pmi_im[eNB][2][1],
                       ue->measurements.subband_pmi_re[eNB][3][1],
                       ue->measurements.subband_pmi_im[eNB][3][1],
                       ue->measurements.subband_pmi_re[eNB][4][1],
                       ue->measurements.subband_pmi_im[eNB][4][1],
                       ue->measurements.subband_pmi_re[eNB][5][1],
                       ue->measurements.subband_pmi_im[eNB][5][1],
                       ue->measurements.subband_pmi_re[eNB][6][1],
                       ue->measurements.subband_pmi_im[eNB][6][1],
                       ue->measurements.subband_pmi_re[eNB][7][1],
                       ue->measurements.subband_pmi_im[eNB][7][1],
                       ue->measurements.subband_pmi_re[eNB][8][1],
                       ue->measurements.subband_pmi_im[eNB][8][1],
                       ue->measurements.subband_pmi_re[eNB][9][1],
                       ue->measurements.subband_pmi_im[eNB][9][1],
                       ue->measurements.subband_pmi_re[eNB][10][1],
                       ue->measurements.subband_pmi_im[eNB][10][1],
                       ue->measurements.subband_pmi_re[eNB][11][1],
                       ue->measurements.subband_pmi_im[eNB][11][1],
                       ue->measurements.subband_pmi_re[eNB][12][1],
                       ue->measurements.subband_pmi_im[eNB][12][1]);
445 446 447

        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d %d %d %d %d]\n",
                       eNB,
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
                       ue->measurements.selected_rx_antennas[eNB][0],
                       ue->measurements.selected_rx_antennas[eNB][1],
                       ue->measurements.selected_rx_antennas[eNB][2],
                       ue->measurements.selected_rx_antennas[eNB][3],
                       ue->measurements.selected_rx_antennas[eNB][4],
                       ue->measurements.selected_rx_antennas[eNB][5],
                       ue->measurements.selected_rx_antennas[eNB][6],
                       ue->measurements.selected_rx_antennas[eNB][7],
                       ue->measurements.selected_rx_antennas[eNB][8],
                       ue->measurements.selected_rx_antennas[eNB][9],
                       ue->measurements.selected_rx_antennas[eNB][10],
                       ue->measurements.selected_rx_antennas[eNB][11],
                       ue->measurements.selected_rx_antennas[eNB][12]);

        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,13)));
463
        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
464 465
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,13)),
                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,13)));
466 467 468 469
        break;
      }

#ifdef OPENAIR2
470
      RRC_status = mac_UE_get_rrc_status(ue->Mod_id, 0);
471 472
      len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status);
#endif
473

474
 
475
      len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d (mode1_flag %d)\n",ue->transmission_mode[eNB],ue->frame_parms.mode1_flag);
476
      len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n",
477 478 479
                     ue->pbch_vars[eNB]->pdu_errors_conseq,
                     ue->pbch_vars[eNB]->pdu_errors,
                     ue->pbch_vars[eNB]->pdu_fer);
480

481 482
      if (ue->transmission_mode[eNB] == 6)
        len += sprintf(&buffer[len], "[UE PROC] Mode 6 Wideband CQI eNB %d : %d dB\n",eNB,ue->measurements.precoded_cqi_dB[eNB][0]);
483

484
      for (harq_pid=0;harq_pid<8;harq_pid++) {
Bilel's avatar
Bilel committed
485
	len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 0 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][0]->harq_processes[harq_pid]->mcs);
486 487
	for (round=0;round<8;round++)
	  len+=sprintf(&buffer[len],"%d/%d ",
Bilel's avatar
Bilel committed
488 489
		       ue->dlsch[0][0][0]->harq_processes[harq_pid]->errors[round],
		       ue->dlsch[0][0][0]->harq_processes[harq_pid]->trials[round]);
490 491
	len+=sprintf(&buffer[len],"\n");
      }
Bilel's avatar
Bilel committed
492 493
      if (ue->dlsch[0][0] && ue->dlsch[0][0][0] && ue->dlsch[0][0][1]) {
        len += sprintf(&buffer[len], "[UE PROC] Saved PMI for DLSCH eNB %d : %jx (%p)\n",eNB,pmi2hex_2Ar1(ue->dlsch[0][0][0]->pmi_alloc),ue->dlsch[0][0][0]);
494

Bilel's avatar
Bilel committed
495
        len += sprintf(&buffer[len], "[UE PROC] eNB %d: dl_power_off = %d\n",eNB,ue->dlsch[0][0][0]->harq_processes[0]->dl_power_off);
496

497
	for (harq_pid=0;harq_pid<8;harq_pid++) {
Bilel's avatar
Bilel committed
498
	  len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 1 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][1]->harq_processes[0]->mcs);
499 500
	  for (round=0;round<8;round++)
	    len+=sprintf(&buffer[len],"%d/%d ",
Bilel's avatar
Bilel committed
501 502
			 ue->dlsch[0][0][1]->harq_processes[harq_pid]->errors[round],
			 ue->dlsch[0][0][1]->harq_processes[harq_pid]->trials[round]);
503 504
	  len+=sprintf(&buffer[len],"\n");
	}
505 506
      }

507 508 509
      len += sprintf(&buffer[len], "[UE PROC] DLSCH Total %d, Error %d, FER %d\n",ue->dlsch_received[0],ue->dlsch_errors[0],ue->dlsch_fer[0]);
      len += sprintf(&buffer[len], "[UE PROC] DLSCH (SI) Total %d, Error %d\n",ue->dlsch_SI_received[0],ue->dlsch_SI_errors[0]);
      len += sprintf(&buffer[len], "[UE PROC] DLSCH (RA) Total %d, Error %d\n",ue->dlsch_ra_received[0],ue->dlsch_ra_errors[0]);
Cedric Roux's avatar
Cedric Roux committed
510
#if defined(Rel10) || defined(Rel14)
511 512
      int i=0;

513 514
      //len += sprintf(&buffer[len], "[UE PROC] MCH  Total %d\n", ue->dlsch_mch_received[0]);
      for(i=0; i <ue->frame_parms.num_MBSFN_config; i++ ) {
515
        len += sprintf(&buffer[len], "[UE PROC] MCH (MCCH MBSFN %d) Total %d, Error %d, Trials %d\n",
516
                       i, ue->dlsch_mcch_received[i][0],ue->dlsch_mcch_errors[i][0],ue->dlsch_mcch_trials[i][0]);
517
        len += sprintf(&buffer[len], "[UE PROC] MCH (MTCH MBSFN %d) Total %d, Error %d, Trials %d\n",
518
                       i, ue->dlsch_mtch_received[i][0],ue->dlsch_mtch_errors[i][0],ue->dlsch_mtch_trials[i][0]);
519
      }
520

521
#endif
522 523 524
      len += sprintf(&buffer[len], "[UE PROC] DLSCH Bitrate %dkbps\n",(ue->bitrate[0]/1000));
      len += sprintf(&buffer[len], "[UE PROC] Total Received Bits %dkbits\n",(ue->total_received_bits[0]/1000));
      len += sprintf(&buffer[len], "[UE PROC] IA receiver %d\n",ue->use_ia_receiver);
525

526 527 528
    }

  } else {
529
    len += sprintf(&buffer[len], "[UE PROC] Frame count: %d, RSSI %3.2f dB (%d dB, %d dB), N0 %3.2f dB (%d dB, %d dB)\n",
530
                   proc->frame_rx,
531 532 533 534 535 536
                   10*log10(ue->measurements.rssi),
                   ue->measurements.rx_power_dB[0][0],
                   ue->measurements.rx_power_dB[0][1],
                   10*log10(ue->measurements.n0_power_tot),
                   ue->measurements.n0_power_dB[0],
                   ue->measurements.n0_power_dB[1]);
537
#ifdef EXMIMO
538
    ue->rx_total_gain_dB = ((int)(10*log10(ue->measurements.rssi)))-input_level_dBm;
539
    len += sprintf(&buffer[len], "[UE PROC] rxg_mode %d, input level (set by user) %d dBm, VGA gain %d dB ==> total gain %3.2f dB, noise figure %3.2f dB\n",
540 541 542
                   openair0_cfg[0].rxg_mode[0],
                   input_level_dBm,
                   (int)openair0_cfg[0].rx_gain[0],
543 544
                   10*log10(ue->measurements.rssi)-input_level_dBm,
                   10*log10(ue->measurements.n0_power_tot)-ue->rx_total_gain_dB+105);
545 546 547 548 549 550 551 552
#endif
  }

  len += sprintf(&buffer[len],"EOF\n");

  return len;
} // is_clusterhead

553

554
int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
555
{
556 557

  unsigned int success=0;
558
  uint8_t eNB_id,UE_id,i,j,number_of_cards_l=1;
559
  uint32_t ulsch_errors=0,dlsch_errors=0;
560 561
  uint32_t ulsch_round_attempts[4]= {0,0,0,0},ulsch_round_errors[4]= {0,0,0,0};
  uint32_t dlsch_round_attempts[4]= {0,0,0,0},dlsch_round_errors[4]= {0,0,0,0};
562
  uint32_t UE_id_mac, RRC_status;
knopp's avatar
knopp committed
563
  eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];
564
  if (eNB==NULL)
565 566 567 568
    return 0;

  int len = length;

569 570 571 572
  //  if(eNB->frame==0){
  eNB->total_dlsch_bitrate = 0;//eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate;
  eNB->total_transmitted_bits = 0;// eNB->UE_stats[UE_id].total_transmitted_bits +  eNB->total_transmitted_bits;
  eNB->total_system_throughput = 0;//eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput;
573 574
  // }

575
  for (eNB_id=0; eNB_id<number_of_cards_l; eNB_id++) {
576
    len += sprintf(&buffer[len],"eNB %d/%d Frame %d: RX Gain %d dB, I0 %d dBm (%d,%d) dB \n",
577
                   eNB_id,number_of_cards_l,
knopp's avatar
knopp committed
578
                   proc->frame_tx,
579 580 581 582
                   eNB->rx_total_gain_dB,
                   eNB->measurements[eNB_id].n0_power_tot_dBm,
                   eNB->measurements[eNB_id].n0_power_dB[0],
                   eNB->measurements[eNB_id].n0_power_dB[1]);
583

584
    len += sprintf(&buffer[len],"PRB I0 (%X.%X.%X.%X): ",
585 586
		   eNB->rb_mask_ul[0],
		   eNB->rb_mask_ul[1],eNB->rb_mask_ul[2],eNB->rb_mask_ul[3]);
587

588
    for (i=0; i<eNB->frame_parms.N_RB_UL; i++) {
589
      len += sprintf(&buffer[len],"%4d ",
590
                     eNB->measurements[eNB_id].n0_subband_power_tot_dBm[i]);
591
      if ((i>0) && ((i%25) == 0)) 
Florian Kaltenberger's avatar
Florian Kaltenberger committed
592
	len += sprintf(&buffer[len],"\n");
593
    }
594
    len += sprintf(&buffer[len],"\n");
595
    len += sprintf(&buffer[len],"\nPERFORMANCE PARAMETERS\n");
596
    /*
597 598 599
    len += sprintf(&buffer[len],"[eNB PROC] Total DLSCH Bitrate for the System %dkbps\n",((eNB->UE_stats[0].dlsch_bitrate + eNB->UE_stats[1].dlsch_bitrate)/1000));
    len += sprintf(&buffer[len],"[eNB PROC] Total Bits successfully transitted %dKbits in %dframe(s)\n",((eNB->UE_stats[0].total_transmitted_bits + eNB->UE_stats[1].total_transmitted_bits)/1000),eNB->frame+1);
    len += sprintf(&buffer[len],"[eNB PROC] Average System Throughput %dKbps\n",(eNB->UE_stats[0].total_transmitted_bits + eNB->UE_stats[1].total_transmitted_bits)/((eNB->frame+1)*10));
600 601
    */

602
    for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
603 604
      if ((eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&&
	  (eNB->UE_stats[UE_id].mode == PUSCH)) {	
605

606 607
        eNB->total_dlsch_bitrate = eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate;
        eNB->total_transmitted_bits = eNB->UE_stats[UE_id].total_TBS + eNB->total_transmitted_bits;
608

609
        //eNB->total_system_throughput = eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput;
610 611
         
	for (i=0; i<8; i++)
612
	  success = success + (eNB->UE_stats[UE_id].dlsch_trials[i][0] - eNB->UE_stats[UE_id].dlsch_l2_errors[i]);
613 614 615

    
	
knopp's avatar
knopp committed
616
	len += sprintf(&buffer[len],"Total DLSCH %d kbits / %d frames ",(eNB->total_transmitted_bits/1000),proc->frame_tx+1);
617
	len += sprintf(&buffer[len],"Total DLSCH throughput %d kbps ",(eNB->total_dlsch_bitrate/1000));
knopp's avatar
knopp committed
618
	len += sprintf(&buffer[len],"Total DLSCH trans %d / %d frames\n",success,proc->frame_tx+1);
619 620 621
	//len += sprintf(&buffer[len],"[eNB PROC] FULL MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->FULL_MUMIMO_transmissions,eNB->check_for_total_transmissions);
	//len += sprintf(&buffer[len],"[eNB PROC] MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_MUMIMO_transmissions,eNB->check_for_total_transmissions);
	//len += sprintf(&buffer[len],"[eNB PROC] SU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_SUMIMO_transmissions,eNB->check_for_total_transmissions);
622 623 624
	
	len += sprintf(&buffer[len],"UE %d (%x) Power: (%d,%d) dB, Po_PUSCH: (%d,%d) dBm, Po_PUCCH (%d/%d) dBm, Po_PUCCH1 (%d,%d) dBm,  PUCCH1 Thres %d dBm \n",
		       UE_id,
625 626 627 628 629 630 631 632 633 634
		       eNB->UE_stats[UE_id].crnti,
		       dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[0]),
		       dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[1]),
		       eNB->UE_stats[UE_id].UL_rssi[0],
		       eNB->UE_stats[UE_id].UL_rssi[1],
		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
		       eNB->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_below/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_above/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
		       PUCCH1_THRES+eNB->measurements[0].n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL));
635 636
	
	len+= sprintf(&buffer[len],"DL mcs %d, UL mcs %d, UL rb %d, delta_TF %d, ",
637 638 639 640
		      eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[0]->mcs,
		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->mcs,
		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->nb_rb,
		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->delta_TF);
641 642
	
	len += sprintf(&buffer[len],"Wideband CQI: (%d,%d) dB\n",
643 644
		       eNB->measurements[eNB_id].wideband_cqi_dB[UE_id][0],
		       eNB->measurements[eNB_id].wideband_cqi_dB[UE_id][1]);
645 646 647
	
	/*	len += sprintf(&buffer[len],"[eNB PROC] Subband CQI:    ");
	
648
	for (i=0; i<eNB->frame_parms.N_RB_DL; i++)
649
	  len += sprintf(&buffer[len],"%2d ",
650
			 eNB->measurements[eNB_id].subband_cqi_tot_dB[UE_id][i]);
651 652 653 654 655
	
	len += sprintf(&buffer[len],"\n");
	*/

	len += sprintf(&buffer[len],"DL TM %d, DL_cqi %d, DL_pmi_single %jx ",
656 657 658
		       eNB->transmission_mode[UE_id],
		       eNB->UE_stats[UE_id].DL_cqi[0],
		       pmi2hex_2Ar1(eNB->UE_stats[UE_id].DL_pmi_single));
659 660

	len += sprintf(&buffer[len],"Timing advance %d samples (%d 16Ts), update %d ",
661 662 663
		       eNB->UE_stats[UE_id].UE_timing_offset,
		       eNB->UE_stats[UE_id].UE_timing_offset>>2,
		       eNB->UE_stats[UE_id].timing_advance_update);
664 665
	
	len += sprintf(&buffer[len],"Mode = %s(%d) ",
666 667 668
		       mode_string[eNB->UE_stats[UE_id].mode],
		       eNB->UE_stats[UE_id].mode);
	UE_id_mac = find_UE_id(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti);
669 670
	
	if (UE_id_mac != -1) {
671
	  RRC_status = mac_eNB_get_rrc_status(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti);
672 673 674 675 676
	  len += sprintf(&buffer[len],"UE_id_mac = %d, RRC status = %d\n",UE_id_mac,RRC_status);
	} else
	  len += sprintf(&buffer[len],"UE_id_mac = -1\n");
	
        len += sprintf(&buffer[len],"SR received/total: %d/%d (diff %d)\n",
677 678 679
                       eNB->UE_stats[UE_id].sr_received,
                       eNB->UE_stats[UE_id].sr_total,
                       eNB->UE_stats[UE_id].sr_total-eNB->UE_stats[UE_id].sr_received);
680 681
	
	len += sprintf(&buffer[len],"DL Subband CQI: ");
682 683

	int nb_sb;
684
	switch (eNB->frame_parms.N_RB_DL) {
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
	case 6:
	  nb_sb=0;
	  break;
	case 15:
	  nb_sb = 4;
	case 25:
	  nb_sb = 7;
	  break;
	case 50:
	  nb_sb = 9;
	  break;
	case 75:
	  nb_sb = 10;
	  break;
	case 100:
	  nb_sb = 13;
	  break;
	default:
	  nb_sb=0;
	  break;
	}	
	for (i=0; i<nb_sb; i++)
707
	  len += sprintf(&buffer[len],"%2d ",
708
			 eNB->UE_stats[UE_id].DL_subband_cqi[0][i]);
709 710 711
	len += sprintf(&buffer[len],"\n");
	

712 713 714 715 716 717 718 719

        ulsch_errors = 0;

        for (j=0; j<4; j++) {
          ulsch_round_attempts[j]=0;
          ulsch_round_errors[j]=0;
        }

720
        len += sprintf(&buffer[len],"ULSCH errors/attempts per harq (per round): \n");
721 722

        for (i=0; i<8; i++) {
723
          len += sprintf(&buffer[len],"   harq %d: %d/%d (fer %d) (%d/%d, %d/%d, %d/%d, %d/%d) ",
724
                         i,
725 726 727 728 729 730 731 732 733 734 735
                         eNB->UE_stats[UE_id].ulsch_errors[i],
                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0],
                         eNB->UE_stats[UE_id].ulsch_round_fer[i][0],
                         eNB->UE_stats[UE_id].ulsch_round_errors[i][0],
                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0],
                         eNB->UE_stats[UE_id].ulsch_round_errors[i][1],
                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][1],
                         eNB->UE_stats[UE_id].ulsch_round_errors[i][2],
                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][2],
                         eNB->UE_stats[UE_id].ulsch_round_errors[i][3],
                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][3]);
736 737 738
	  if ((i&1) == 1)
	    len += sprintf(&buffer[len],"\n");
	    
739
          ulsch_errors+=eNB->UE_stats[UE_id].ulsch_errors[i];
740 741

          for (j=0; j<4; j++) {
742 743
            ulsch_round_attempts[j]+=eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][j];
            ulsch_round_errors[j]+=eNB->UE_stats[UE_id].ulsch_round_errors[i][j];
744 745 746
          }
        }

747
        len += sprintf(&buffer[len],"ULSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d)\n",
748 749 750 751 752 753 754 755 756 757 758 759 760 761
                       ulsch_errors,ulsch_round_attempts[0],

                       ulsch_round_errors[0],ulsch_round_attempts[0],
                       ulsch_round_errors[1],ulsch_round_attempts[1],
                       ulsch_round_errors[2],ulsch_round_attempts[2],
                       ulsch_round_errors[3],ulsch_round_attempts[3]);

        dlsch_errors = 0;

        for (j=0; j<4; j++) {
          dlsch_round_attempts[j]=0;
          dlsch_round_errors[j]=0;
        }

762
        len += sprintf(&buffer[len],"DLSCH errors/attempts per harq (per round): \n");
763 764

        for (i=0; i<8; i++) {
765
          len += sprintf(&buffer[len],"   harq %d: %d/%d (%d/%d/%d, %d/%d/%d, %d/%d/%d, %d/%d/%d) ",
766
                         i,
767 768 769 770 771 772 773 774 775 776 777 778 779 780
                         eNB->UE_stats[UE_id].dlsch_l2_errors[i],
                         eNB->UE_stats[UE_id].dlsch_trials[i][0],
                         eNB->UE_stats[UE_id].dlsch_ACK[i][0],
                         eNB->UE_stats[UE_id].dlsch_NAK[i][0],
                         eNB->UE_stats[UE_id].dlsch_trials[i][0],
                         eNB->UE_stats[UE_id].dlsch_ACK[i][1],
                         eNB->UE_stats[UE_id].dlsch_NAK[i][1],
                         eNB->UE_stats[UE_id].dlsch_trials[i][1],
                         eNB->UE_stats[UE_id].dlsch_ACK[i][2],
                         eNB->UE_stats[UE_id].dlsch_NAK[i][2],
                         eNB->UE_stats[UE_id].dlsch_trials[i][2],
                         eNB->UE_stats[UE_id].dlsch_ACK[i][3],
                         eNB->UE_stats[UE_id].dlsch_NAK[i][3],
                         eNB->UE_stats[UE_id].dlsch_trials[i][3]);
781 782 783 784
	  if ((i&1) == 1)
	    len += sprintf(&buffer[len],"\n");


785
          dlsch_errors+=eNB->UE_stats[UE_id].dlsch_l2_errors[i];
786 787

          for (j=0; j<4; j++) {
788 789
            dlsch_round_attempts[j]+=eNB->UE_stats[UE_id].dlsch_trials[i][j];
            dlsch_round_errors[j]+=eNB->UE_stats[UE_id].dlsch_NAK[i][j];
790 791 792
          }
        }

793
        len += sprintf(&buffer[len],"DLSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d): \n",
794 795 796 797 798 799 800
                       dlsch_errors,dlsch_round_attempts[0],
                       dlsch_round_errors[0],dlsch_round_attempts[0],
                       dlsch_round_errors[1],dlsch_round_attempts[1],
                       dlsch_round_errors[2],dlsch_round_attempts[2],
                       dlsch_round_errors[3],dlsch_round_attempts[3]);


801 802 803 804
        len += sprintf(&buffer[len],"DLSCH total bits from MAC: %dkbit ",(eNB->UE_stats[UE_id].total_TBS_MAC)/1000);
        len += sprintf(&buffer[len],"DLSCH total bits ack'ed: %dkbit ",(eNB->UE_stats[UE_id].total_TBS)/1000);
        len += sprintf(&buffer[len],"DLSCH Average throughput (100 frames): %dkbps\n",(eNB->UE_stats[UE_id].dlsch_bitrate/1000));
	//        len += sprintf(&buffer[len],"[eNB PROC] Transmission Mode %d\n",eNB->transmission_mode[UE_id]);
805
	/*
806 807
        if(eNB->transmission_mode[UE_id] == 5) {
          if(eNB->mu_mimo_mode[UE_id].dl_pow_off == 0)
808
            len += sprintf(&buffer[len],"[eNB PROC] ****UE %d is in MU-MIMO mode****\n",UE_id);
809
          else if(eNB->mu_mimo_mode[UE_id].dl_pow_off == 1)
810 811 812 813
            len += sprintf(&buffer[len],"[eNB PROC] ****UE %d is in SU-MIMO mode****\n",UE_id);
          else
            len += sprintf(&buffer[len],"[eNB PROC] ****UE %d is not scheduled****\n",UE_id);
        }
814 815
	*/
	/*
816 817
        len += sprintf(&buffer[len],"[eNB PROC] RB Allocation on Sub-bands: ");

818
        //  for (j=0;j< mac_xface->frame_parms->N_RBGS;j++)
819 820
        for (j=0; j<7; j++)
          len += sprintf(&buffer[len],"%d ",
821
                         eNB->mu_mimo_mode[UE_id].rballoc_sub[j]);
822 823

        len += sprintf(&buffer[len],"\n");
824
        len += sprintf(&buffer[len],"[eNB PROC] Total Number of Allocated PRBs = %d\n",eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs);
825
	*/
826 827
      }
    }
828

829 830
    len += sprintf(&buffer[len],"\n");
  }
831
  
832
  len += sprintf(&buffer[len],"EOF\n");
833
  
834 835
  return len;
}