if4_tools.c 5.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*******************************************************************************
    OpenAirInterface
    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
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.

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

  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

 *******************************************************************************/

/*! \file PHY/LTE_TRANSPORT/if4_tools.c
* \brief 
Sandeep Kumar's avatar
Sandeep Kumar committed
32
* \author Mauricio Gunther, S. Sandeep Kumar, Raymond Knopp
33 34 35
* \date 2016
* \version 0.1
* \company Eurecom
Sandeep Kumar's avatar
Sandeep Kumar committed
36
* \email: knopp@eurecom.fr 
37 38 39 40
* \note
* \warning
*/

Sandeep Kumar's avatar
Sandeep Kumar committed
41 42 43 44
#ifndef USER_MODE
#include "if4_tools.h"
#include <stdint.h>
#else
45
#include "PHY/LTE_TRANSPORT/if4_tools.h"
Sandeep Kumar's avatar
Sandeep Kumar committed
46
#endif
47

48 49 50 51
void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) {
	int frame = proc->frame_tx;
	int subframe = proc->subframe_tx;
	LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
52
	
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
	uint16_t i;

  float_t data_block_length = 1200*(fp->ofdm_symbol_size/2048);
  uint16_t *data_block = (uint16_t*)malloc(data_block_length*sizeof(uint16_t));

  // Caller: RCC - DL *** handle RRU case - UL and PRACH *** 
  if (eNB->node_function == NGFI_RCC_IF4) {
    IF4_dl_packet_t *dl_packet = (IF4_dl_packet_t*)malloc(sizeof_IF4_dl_packet_t);
    gen_IF4_dl_packet(dl_packet, proc);
		
    dl_packet->data_block = data_block;

    for(i=0; i<fp->symbols_per_tti; i++) {
			
      //Do compression of the two parts and generate data blocks

      //symbol = eNB->common_vars.txdataF[0][0 /*antenna number*/][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)]
      //data_block[j] = Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j -1])<<16 + Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j]);
      //data_block[j+NrOfNonZeroValues] = Atan(subframe[i][j+1])<<16 + Atan(subframe[i][j+2]);
	 		
      // Update information in generated packet
      dl_packet->frame_status.sym_num = i; 
			
      // Write the packet(s) to the fronthaul 

    }
  }else {
    IF4_ul_packet_t *ul_packet = (IF4_ul_packet_t*)malloc(sizeof_IF4_ul_packet_t);
    gen_IF4_ul_packet(ul_packet, proc);
		
    ul_packet->data_block = data_block;

    for(i=0; i<fp->symbols_per_tti; i++) {
			
      //Do compression of the two parts and generate data blocks

      //symbol = eNB->common_vars.txdataF[0][0 /*antenna number*/][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)]
      //data_block[j] = Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j -1])<<16 + Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j]);
      //data_block[j+NrOfNonZeroValues] = Atan(subframe[i][j+1])<<16 + Atan(subframe[i][j+2]);
			
      // Update information in generated packet
      ul_packet->frame_status.sym_num = i; 
			
      // Write the packet(s) to the fronthaul 

    }		
	}
Sandeep Kumar's avatar
Sandeep Kumar committed
100
  		    
101
}
102

103
void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) {
Sandeep Kumar's avatar
Sandeep Kumar committed
104 105 106 107 108 109

  // Read packet(s) from the fronthaul
  
  // Apply reverse processing - decompression
  
  // Generate and return the OFDM symbols (txdataF)
110 111 112

  // Caller: RRU - DL *** handle RCC case - UL and PRACH *** 
	  
113 114
}

115
void gen_IF4_dl_packet(IF4_dl_packet_t *dl_packet, eNB_rxtx_proc_t *proc) {      
Sandeep Kumar's avatar
Sandeep Kumar committed
116
  // Set Type and Sub-Type
117 118
  dl_packet->type = 0x080A; 
  dl_packet->sub_type = 0x0020;
Sandeep Kumar's avatar
Sandeep Kumar committed
119 120

  // Leave reserved as it is 
121
  dl_packet->rsvd = 0;
Sandeep Kumar's avatar
Sandeep Kumar committed
122 123
  
  // Set frame status
124 125 126 127 128 129 130
  dl_packet->frame_status.ant_num = 0;
  dl_packet->frame_status.ant_start = 0;
  dl_packet->frame_status.rf_num = proc->frame_tx;
  dl_packet->frame_status.sf_num = proc->subframe_tx;
  dl_packet->frame_status.sym_num = 0;
  dl_packet->frame_status.rsvd = 0;

Sandeep Kumar's avatar
Sandeep Kumar committed
131
  // Set frame check sequence
132
  dl_packet->fcs = 0;
133 134
}

135
void gen_IF4_ul_packet(IF4_ul_packet_t *ul_packet, eNB_rxtx_proc_t *proc) {  
Sandeep Kumar's avatar
Sandeep Kumar committed
136
  // Set Type and Sub-Type
137 138
  ul_packet->type = 0x080A; 
  ul_packet->sub_type = 0x0019;
Sandeep Kumar's avatar
Sandeep Kumar committed
139 140

  // Leave reserved as it is 
141
  ul_packet->rsvd = 0;
Sandeep Kumar's avatar
Sandeep Kumar committed
142 143
  
  // Set frame status
144 145 146 147 148 149 150 151 152 153
  ul_packet->frame_status.ant_num = 0;
  ul_packet->frame_status.ant_start = 0;
  ul_packet->frame_status.rf_num = proc->frame_rx;
  ul_packet->frame_status.sf_num = proc->subframe_rx;
  ul_packet->frame_status.sym_num = 0;
  ul_packet->frame_status.rsvd = 0;
    
  // Set antenna specific gain *** set other antenna gain ***
  ul_packet->gain0.exponent = 0;
  ul_packet->gain0.rsvd = 0;
Sandeep Kumar's avatar
Sandeep Kumar committed
154 155
    
  // Set frame check sequence
156
  ul_packet->fcs = 0;
157 158
}

159
void gen_IF4_prach_packet(IF4_prach_packet_t *prach_packet, eNB_rxtx_proc_t *proc) {
Sandeep Kumar's avatar
Sandeep Kumar committed
160
  // Set Type and Sub-Type
161 162
  prach_packet->type = 0x080A; 
  prach_packet->sub_type = 0x0021;
Sandeep Kumar's avatar
Sandeep Kumar committed
163 164

  // Leave reserved as it is 
165
  prach_packet->rsvd = 0;
Sandeep Kumar's avatar
Sandeep Kumar committed
166 167
  
  // Set LTE Prach configuration
168 169 170 171 172 173
  prach_packet->prach_conf.rsvd = 0;
  prach_packet->prach_conf.ant = 0;
  prach_packet->prach_conf.rf_num = proc->frame_rx;
  prach_packet->prach_conf.sf_num = proc->subframe_rx;
  prach_packet->prach_conf.exponent = 0;  
        
Sandeep Kumar's avatar
Sandeep Kumar committed
174
  // Set frame check sequence
175
  prach_packet->fcs = 0;
176
}