if5_tools.c 7.85 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
24
25
26
27
28
29
30
31
32
33
34
35
/*! \file PHY/LTE_TRANSPORT/if5_tools.c
* \brief 
* \author S. Sandeep Kumar, Raymond Knopp
* \date 2016
* \version 0.1
* \company Eurecom
* \email: ee13b1025@iith.ac.in, knopp@eurecom.fr 
* \note
* \warning
*/

#include "PHY/defs.h"

#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
36
#include "UTIL/LOG/vcd_signal_dumper.h"
37

Sandeep Kumar's avatar
Sandeep Kumar committed
38
void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) {      
39
40
  
  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
41
42
  int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; 
  int32_t *tx_buffer=NULL;
43
44

  uint16_t packet_id=0, i=0;
Sandeep Kumar's avatar
Sandeep Kumar committed
45
46
47

  uint32_t spp_eth  = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_packet;
  uint32_t spsf     = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_frame/10;
48
  
49
50
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 );  

Sandeep Kumar's avatar
Sandeep Kumar committed
51
52
  if (packet_type == IF5_RRH_GW_DL) {    

53
    for (i=0; i < fp->nb_antennas_tx; i++)
Sandeep Kumar's avatar
Sandeep Kumar committed
54
      txp[i] = (void*)&eNB->common_vars.txdata[0][i][subframe*fp->samples_per_tti];
55
56
    
    for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
Raymond Knopp's avatar
Raymond Knopp committed
57
58

      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );            
59
      eNB->ifdevice.trx_write_func(&eNB->ifdevice,
Sandeep Kumar's avatar
Sandeep Kumar committed
60
                                   (proc_timestamp + packet_id*spp_eth),
61
                                   (void**)txp,
62
63
64
                                   spp_eth,
                                   fp->nb_antennas_tx,
                                   0);
Raymond Knopp's avatar
Raymond Knopp committed
65
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );  
Sandeep Kumar's avatar
Sandeep Kumar committed
66
67
68
      for (i=0; i < fp->nb_antennas_tx; i++)
        txp[i] += spp_eth;

69
70
    }
    
Sandeep Kumar's avatar
Sandeep Kumar committed
71
  } else if (packet_type == IF5_RRH_GW_UL) {
Sandeep Kumar's avatar
Sandeep Kumar committed
72
        
Sandeep Kumar's avatar
Sandeep Kumar committed
73
74
75
76
    for (i=0; i < fp->nb_antennas_rx; i++)
      rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti];
    
    for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
Sandeep Kumar's avatar
Sandeep Kumar committed
77

Raymond Knopp's avatar
Raymond Knopp committed
78
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );            
Sandeep Kumar's avatar
Sandeep Kumar committed
79
80
      eNB->ifdevice.trx_write_func(&eNB->ifdevice,
                                   (proc_timestamp + packet_id*spp_eth),
81
                                   (void**)rxp,
Sandeep Kumar's avatar
Sandeep Kumar committed
82
83
84
                                   spp_eth,
                                   fp->nb_antennas_rx,
                                   0);
Raymond Knopp's avatar
Raymond Knopp committed
85
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );            
Sandeep Kumar's avatar
Sandeep Kumar committed
86
87
88
      for (i=0; i < fp->nb_antennas_rx; i++)
        rxp[i] += spp_eth;

Sandeep Kumar's avatar
Sandeep Kumar committed
89
    }    
90
    
Sandeep Kumar's avatar
Sandeep Kumar committed
91
  } else if (packet_type == IF5_MOBIPASS) {    
92
93
94
95
96
97
98
99
    uint16_t db_fulllength=640;
    
    __m128i *data_block=NULL, *data_block_head=NULL;

    __m128i *txp128;
    __m128i t0, t1;

    tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t));
100
101
    IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES);
    data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 4);
102
103
104
105
106
107
108
    
    header->flags = 0;
    header->fifo_status = 0;  
    header->seqno = *seqno;
    header->ack = 0;
    header->word0 = 0;  
    
Sandeep Kumar's avatar
Sandeep Kumar committed
109
    txp[0] = (void*)&eNB->common_vars.txdata[0][0][subframe*eNB->frame_parms.samples_per_tti];
110
111
    txp128 = (__m128i *) txp[0];
              
112
113
    for (packet_id=0; packet_id<fp->samples_per_tti/db_fulllength; packet_id++) {
      header->time_stamp = (uint32_t)(proc_timestamp + packet_id*db_fulllength);
114
115
      data_block = data_block_head; 
    
116
      for (i=0; i<db_fulllength>>2; i+=2) {
117
118
        t0 = _mm_srai_epi16(*txp128++, 4);
        t1 = _mm_srai_epi16(*txp128++, 4);   
119
120
121
122
123
124
125
        
        *data_block++ = _mm_packs_epi16(t0, t1);     
      }
      
      // Write the packet to the fronthaul
      if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
                                        packet_id,
126
                                        (void**)&tx_buffer,
127
128
129
130
131
132
133
134
135
                                        db_fulllength,
                                        1,
                                        IF5_MOBIPASS)) < 0) {
        perror("ETHERNET write for IF5_MOBIPASS\n");
      }
    
      header->seqno += 1;    
    }  
    *seqno = header->seqno;
Sandeep Kumar's avatar
Sandeep Kumar committed
136
    
137
138
139
140
141
  } else {    
    AssertFatal(1==0, "send_IF5 - Unknown packet_type %x", packet_type);     
  }  
  
  free(tx_buffer);
142
143
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 );  

144
145
146
147
  return;  		    
}


Sandeep Kumar's avatar
Sandeep Kumar committed
148
void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subframe, uint16_t packet_type) {
149
150

  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
151
152
  int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; 

153
  uint16_t packet_id=0, i=0;
Sandeep Kumar's avatar
Sandeep Kumar committed
154
155
156
157
158

  int32_t spp_eth  = (int32_t) eNB->ifdevice.openair0_cfg->samples_per_packet;
  int32_t spsf     = (int32_t) eNB->ifdevice.openair0_cfg->samples_per_frame/10;

  openair0_timestamp timestamp[spsf / spp_eth];
159
160

  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 1 );  
161
  
Sandeep Kumar's avatar
Sandeep Kumar committed
162
  if (packet_type == IF5_RRH_GW_DL) {
Sandeep Kumar's avatar
Sandeep Kumar committed
163
        
Sandeep Kumar's avatar
Sandeep Kumar committed
164
165
    for (i=0; i < fp->nb_antennas_tx; i++)
      txp[i] = (void*)&eNB->common_vars.txdata[0][i][subframe*fp->samples_per_tti];
166
167
    
    for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
Sandeep Kumar's avatar
Sandeep Kumar committed
168

Raymond Knopp's avatar
Raymond Knopp committed
169
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 1 );  
170
171
      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
                                  &timestamp[packet_id],
172
                                  (void**)txp,
173
                                  spp_eth,
Sandeep Kumar's avatar
Sandeep Kumar committed
174
                                  fp->nb_antennas_tx);
Raymond Knopp's avatar
Raymond Knopp committed
175
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );  
Sandeep Kumar's avatar
Sandeep Kumar committed
176
177
178
      for (i=0; i < fp->nb_antennas_tx; i++)
        txp[i] += spp_eth;

179
180
    }
    
Sandeep Kumar's avatar
Sandeep Kumar committed
181
182
    *proc_timestamp = timestamp[0];
    
Sandeep Kumar's avatar
Sandeep Kumar committed
183
  } else if (packet_type == IF5_RRH_GW_UL) { 
Sandeep Kumar's avatar
Sandeep Kumar committed
184
185
186
    
    for (i=0; i < fp->nb_antennas_rx; i++)
      rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti];
187
    
Sandeep Kumar's avatar
Sandeep Kumar committed
188
    for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
Raymond Knopp's avatar
Raymond Knopp committed
189
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 1 );            
Sandeep Kumar's avatar
Sandeep Kumar committed
190
191
      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
                                  &timestamp[packet_id],
192
                                  (void**)rxp,
Sandeep Kumar's avatar
Sandeep Kumar committed
193
194
                                  spp_eth,
                                  fp->nb_antennas_rx);
Raymond Knopp's avatar
Raymond Knopp committed
195
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );            
Sandeep Kumar's avatar
Sandeep Kumar committed
196
197
198
      for (i=0; i < fp->nb_antennas_rx; i++)
        rxp[i] += spp_eth;

Sandeep Kumar's avatar
Sandeep Kumar committed
199
200
201
202
    }

    *proc_timestamp = timestamp[0];
      
203
204
205
206
207
208
  } else if (packet_type == IF5_MOBIPASS) {
    
    
  } else {
    AssertFatal(1==0, "recv_IF5 - Unknown packet_type %x", packet_type);     
  }  
209
210

  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 0 );  
211
212
213
  
  return;  
}