From 79c8d0e0cbf842f1f03d21d492457235faf8e71a Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Sat, 10 Mar 2018 16:19:40 +0100
Subject: [PATCH] updates for IF4p5 to handle >1 nb_rx/nb_tx. Tested with 2x2

---
 openair1/PHY/INIT/lte_init_ru.c               |   4 +-
 openair1/PHY/LTE_TRANSPORT/if4_tools.c        | 240 ++++++++++--------
 .../CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf    |   8 +-
 targets/RT/USER/lte-ru.c                      |   2 +-
 4 files changed, 136 insertions(+), 118 deletions(-)

diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c
index eb56cb04d3c..917809a5c91 100644
--- a/openair1/PHY/INIT/lte_init_ru.c
+++ b/openair1/PHY/INIT/lte_init_ru.c
@@ -91,8 +91,8 @@ int phy_init_RU(RU_t *ru) {
     }
 
     /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */
-    AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]),
-		"nb_antennas_rx too large");
+    //AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]),
+		//"nb_antennas_rx too large");
     ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
     for (j=0;j<4;j++) ru->prach_rxsigF_br[j] = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
 
diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
index 17e2aa08a7e..d9544e8f831 100644
--- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
@@ -90,14 +90,18 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
 
     AssertFatal(txdataF[0]!=NULL,"txdataF_BF[0] is null\n");
     for (symbol_id=0; symbol_id<nsym; symbol_id++) {
-      for (element_id=0; element_id<db_halflength; element_id++) {
-        i = (uint16_t*) &txdataF[0][blockoffsetF+element_id];
-        data_block[element_id] = ((uint16_t) lin2alaw_if4p5[*i]) | (lin2alaw_if4p5[*(i+1)]<<8);
+      for (int antenna_id=0; antenna_id<ru->nb_tx; antenna_id++) {
+        for (element_id=0; element_id<db_halflength; element_id++) {
+          i = (uint16_t*) &txdataF[antenna_id][blockoffsetF+element_id];
+          data_block[element_id] = ((uint16_t) lin2alaw_if4p5[*i]) | (lin2alaw_if4p5[*(i+1)]<<8);
 
-        i = (uint16_t*) &txdataF[0][slotoffsetF+element_id];
-        data_block[element_id+db_halflength] = ((uint16_t) lin2alaw_if4p5[*i]) | (lin2alaw_if4p5[*(i+1)]<<8);        
+          i = (uint16_t*) &txdataF[antenna_id][slotoffsetF+element_id];
+          data_block[element_id+db_halflength] = ((uint16_t) lin2alaw_if4p5[*i]) | (lin2alaw_if4p5[*(i+1)]<<8);        
+        }
       }
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 );
+      packet_header->frame_status &= ~(0x7);
+      packet_header->frame_status |= (ru->nb_tx-1);
 				 		
       packet_header->frame_status &= ~(0x000f<<26);
       packet_header->frame_status |= (symbol_id&0x000f)<<26; 
@@ -105,7 +109,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
       if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
 				       symbol_id,
 				       &tx_buffer,
-				       db_fulllength, 
+				       db_fulllength*ru->nb_tx, 
 				       1,
 				       IF4p5_PDLFFT)) < 0) {
         perror("ETHERNET write for IF4p5_PDLFFT\n");
@@ -139,42 +143,45 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
     if (packet_type == IF4p5_PULFFT) {
 
       for (symbol_id=fp->symbols_per_tti-nsym; symbol_id<fp->symbols_per_tti; symbol_id++) {
-
-	uint32_t *rx0 = (uint32_t*) &rxdataF[0][blockoffsetF];
-	uint32_t *rx1 = (uint32_t*) &rxdataF[0][slotoffsetF];
-
-	VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF4_SYMBOL, symbol_id );
-	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 1 );		
-
-	start_meas(&ru->compression);
-
-	for (element_id=0; element_id<db_halflength; element_id+=8) {
-	  i = (uint16_t*) &rx0[element_id];
-          d = (uint16_t*) &data_block[element_id];
-          d[0] = ((uint16_t) lin2alaw_if4p5[i[0]])  | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8));
-          d[1] = ((uint16_t) lin2alaw_if4p5[i[2]])  | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8));
-          d[2] = ((uint16_t) lin2alaw_if4p5[i[4]])  | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8));
-          d[3] = ((uint16_t) lin2alaw_if4p5[i[6]])  | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8));
-          d[4] = ((uint16_t) lin2alaw_if4p5[i[8]])  | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8));
-          d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8));
-          d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8));
-          d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8));
-
-          i = (uint16_t*) &rx1[element_id];
-          d = (uint16_t*) &data_block[element_id+db_halflength];
-          d[0] = ((uint16_t) lin2alaw_if4p5[i[0]])  | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8));
-          d[1] = ((uint16_t) lin2alaw_if4p5[i[2]])  | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8));
-          d[2] = ((uint16_t) lin2alaw_if4p5[i[4]])  | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8));
-          d[3] = ((uint16_t) lin2alaw_if4p5[i[6]])  | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8));
-          d[4] = ((uint16_t) lin2alaw_if4p5[i[8]])  | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8));
-          d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8));
-          d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8));
-          d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8));
-
+        for (int antenna_id=0;antenna_id<ru->nb_rx;antenna_id++) {
+
+	   uint32_t *rx0 = (uint32_t*) &rxdataF[antenna_id][blockoffsetF];
+	   uint32_t *rx1 = (uint32_t*) &rxdataF[antenna_id][slotoffsetF];
+
+	   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF4_SYMBOL, symbol_id );
+	   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 1 );		
+
+	   start_meas(&ru->compression);
+
+	   for (element_id=0; element_id<db_halflength; element_id+=8) {
+	     i = (uint16_t*) &rx0[element_id];
+             d = (uint16_t*) &data_block[element_id];
+             d[0] = ((uint16_t) lin2alaw_if4p5[i[0]])  | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8));
+             d[1] = ((uint16_t) lin2alaw_if4p5[i[2]])  | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8));
+             d[2] = ((uint16_t) lin2alaw_if4p5[i[4]])  | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8));
+             d[3] = ((uint16_t) lin2alaw_if4p5[i[6]])  | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8));
+             d[4] = ((uint16_t) lin2alaw_if4p5[i[8]])  | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8));
+             d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8));
+             d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8));
+             d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8));
+
+             i = (uint16_t*) &rx1[element_id];
+             d = (uint16_t*) &data_block[element_id+db_halflength];
+             d[0] = ((uint16_t) lin2alaw_if4p5[i[0]])  | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8));
+             d[1] = ((uint16_t) lin2alaw_if4p5[i[2]])  | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8));
+             d[2] = ((uint16_t) lin2alaw_if4p5[i[4]])  | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8));
+             d[3] = ((uint16_t) lin2alaw_if4p5[i[6]])  | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8));
+             d[4] = ((uint16_t) lin2alaw_if4p5[i[8]])  | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8));
+             d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8));
+             d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8));
+             d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8));
+
+          }
         }
-
         stop_meas(&ru->compression);
         VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 );   	
+        packet_header->frame_status &= ~(0x07);
+        packet_header->frame_status |= ru->nb_rx-1;
 	packet_header->frame_status &= ~(0x000f<<26);
 	packet_header->frame_status |= (symbol_id&0x000f)<<26; 
 	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );  
@@ -182,7 +189,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
 	if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
 					 symbol_id,
 					 &tx_buffer,
-					 db_fulllength,
+					 db_fulllength*ru->nb_rx,
 					 1,
 					 IF4p5_PULFFT)) < 0) {
 	  perror("ETHERNET write for IF4p5_PULFFT\n");
@@ -221,28 +228,30 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
 
     int16_t *rxF;
 
+    for (int antenna_id=0;antenna_id<ru->nb_rx;antenna_id++) {
 #ifdef Rel14
-    if (packet_type > IF4p5_PRACH)
-      rxF = &prach_rxsigF_br[packet_type - IF4p5_PRACH - 1][0][0];
-    else 
+      if (packet_type > IF4p5_PRACH)
+        rxF = &prach_rxsigF_br[packet_type - IF4p5_PRACH - 1][0][0];
+      else 
 #endif
-      rxF = &prach_rxsigF[0][0];
-
-    AssertFatal(rxF!=NULL,"rxF is null\n");
-    if (eth->flags == ETH_RAW_IF4p5_MODE) {
-      memcpy((void *)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
-	     (void*)rxF, 
-	     PRACH_BLOCK_SIZE_BYTES);
-    } else {
-      memcpy((void *)(tx_buffer_prach + sizeof_IF4p5_header_t),
-             (void *)rxF,
-             PRACH_BLOCK_SIZE_BYTES);
+      rxF = &prach_rxsigF[antenna_id][0];
+
+      AssertFatal(rxF!=NULL,"rxF is null\n");
+      if (eth->flags == ETH_RAW_IF4p5_MODE) {
+        memcpy((void *)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t+PRACH_BLOCK_SIZE_BYTES*antenna_id),
+	       (void*)rxF, 
+	       PRACH_BLOCK_SIZE_BYTES);
+      } else {
+        memcpy((void *)(tx_buffer_prach + sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES*antenna_id),
+               (void *)rxF,
+               PRACH_BLOCK_SIZE_BYTES);
+      }
     }
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );
     if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
 				     symbol_id,
 				     &tx_buffer_prach,
-				     db_fulllength,
+				     db_fulllength*ru->nb_rx,
 				     1,
 				     packet_type)) < 0) {
       perror("ETHERNET write for IF4p5_PRACH\n");
@@ -276,9 +285,9 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
   if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );   
   
   if (ru->function == NGFI_RRU_IF4p5) {
-    db_fulllength = (12*fp->N_RB_DL); 
+    db_fulllength = (12*fp->N_RB_DL)*ru->nb_tx; 
   } else { // This is not an RRU
-    db_fulllength = (12*fp->N_RB_UL);     
+    db_fulllength = (12*fp->N_RB_UL)*ru->nb_rx;     
   }  
   db_halflength = db_fulllength>>1;
 
@@ -316,7 +325,9 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
 
   *packet_type = packet_header->sub_type; 
   LOG_D(PHY,"recv_IF4p5: Frame %d, Subframe %d: packet_type %x\n",*frame,*subframe,*packet_type);
-  if (*packet_type == IF4p5_PDLFFT) {          
+  if (*packet_type == IF4p5_PDLFFT) {
+    db_fulllength/=ru->nb_tx;
+    db_halflength/=ru->nb_tx;          
     *symbol_number = ((packet_header->frame_status)>>26)&0x000f;         
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RECV_IF4_SYMBOL, *symbol_number );
     LOG_D(PHY,"DL_IF4p5: RU %d frame %d, subframe %d, symbol %d\n",ru->idx,*frame,*subframe,*symbol_number);
@@ -324,18 +335,22 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
     slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size)+1;// + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
     blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; 
     
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );    
-    for (element_id=0; element_id<db_halflength; element_id++) {
-      i = (uint16_t*) &txdataF[0][blockoffsetF+element_id];
-      *i = alaw2lin_if4p5[ (data_block[element_id] & 0xff) ]; 
-      *(i+1) = alaw2lin_if4p5[ (data_block[element_id]>>8) ];
-
-      i = (uint16_t*) &txdataF[0][slotoffsetF+element_id];
-      *i = alaw2lin_if4p5[ (data_block[element_id+db_halflength] & 0xff) ]; 
-      *(i+1) = alaw2lin_if4p5[ (data_block[element_id+db_halflength]>>8) ];
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );
+    for (int antenna_id=0;antenna_id<ru->nb_tx;antenna_id++) {    
+      for (element_id=0; element_id<db_halflength; element_id++) {
+        i = (uint16_t*) &txdataF[antenna_id][blockoffsetF+element_id];
+        *i = alaw2lin_if4p5[ (data_block[element_id] & 0xff) ]; 
+        *(i+1) = alaw2lin_if4p5[ (data_block[element_id]>>8) ];
+
+        i = (uint16_t*) &txdataF[antenna_id][slotoffsetF+element_id];
+        *i = alaw2lin_if4p5[ (data_block[element_id+db_halflength] & 0xff) ]; 
+        *(i+1) = alaw2lin_if4p5[ (data_block[element_id+db_halflength]>>8) ];
+      }
     }
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 );		        
-  } else if (*packet_type == IF4p5_PULFFT) {         
+  } else if (*packet_type == IF4p5_PULFFT) {
+    db_fulllength/=ru->nb_rx;
+    db_halflength/=ru->nb_rx;         
     *symbol_number = ((packet_header->frame_status)>>26)&0x000f;         
 
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RECV_IF4_SYMBOL, *symbol_number );
@@ -343,50 +358,53 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
 
 
     slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size);
-    blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; 
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );  
-    for (element_id=0; element_id<db_halflength; element_id++) {
-      i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id];
-      *i = alaw2lin_if4p5[ (data_block[element_id] & 0xff) ]; 
-      *(i+1) = alaw2lin_if4p5[ (data_block[element_id]>>8) ];
+    blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength;
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );
+    for (int antenna_id=0;antenna_id<ru->nb_rx;antenna_id++) { 
+      for (element_id=0; element_id<db_halflength; element_id++) {
+        i = (uint16_t*) &rxdataF[antenna_id][blockoffsetF+element_id];
+        *i = alaw2lin_if4p5[ (data_block[element_id] & 0xff) ]; 
+        *(i+1) = alaw2lin_if4p5[ (data_block[element_id]>>8) ];
 
-      i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id];
-      *i = alaw2lin_if4p5[ (data_block[element_id+db_halflength] & 0xff) ]; 
-      *(i+1) = alaw2lin_if4p5[ (data_block[element_id+db_halflength]>>8) ];
+        i = (uint16_t*) &rxdataF[antenna_id][slotoffsetF+element_id];
+        *i = alaw2lin_if4p5[ (data_block[element_id+db_halflength] & 0xff) ]; 
+        *(i+1) = alaw2lin_if4p5[ (data_block[element_id+db_halflength]>>8) ];
 
 	//if (element_id==0) LOG_I(PHY,"recv_if4p5: symbol %d rxdata0 = (%u,%u)\n",*symbol_number,*i,*(i+1));
+      }
+      LOG_D(PHY,"PULFFT_IF4p5: CC_id %d : frame %d, subframe %d (symbol %d)=> %d dB\n",ru->idx,*frame,*subframe,*symbol_number,
+  	    dB_fixed(signal_energy((int*)&rxdataF[antenna_id][slotoffsetF],db_halflength)+
+	  	     signal_energy((int*)&rxdataF[antenna_id][blockoffsetF],db_halflength)));
     }
-    LOG_D(PHY,"PULFFT_IF4p5: CC_id %d : frame %d, subframe %d (symbol %d)=> %d dB\n",ru->idx,*frame,*subframe,*symbol_number,
-	  dB_fixed(signal_energy((int*)&rxdataF[0][slotoffsetF],db_halflength)+
-		   signal_energy((int*)&rxdataF[0][blockoffsetF],db_halflength)));
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 );		
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 );	
   } else if (*packet_type >= IF4p5_PRACH &&
 	     *packet_type <= IF4p5_PRACH + 4) {  
 
     int16_t *rxF;
-    
+   
+    for (int antenna_id=0;antenna_id<ru->nb_rx;antenna_id++) { 
 #ifdef Rel14
-    if (*packet_type > IF4p5_PRACH)
-      rxF = &prach_rxsigF_br[*packet_type - IF4p5_PRACH - 1][0][0];
-    else 
+      if (*packet_type > IF4p5_PRACH)
+        rxF = &prach_rxsigF_br[*packet_type - IF4p5_PRACH - 1][antenna_id][0];
+      else 
 #endif
-      rxF = &prach_rxsigF[0][0];
+      rxF = &prach_rxsigF[antenna_id][0];
 
     // FIX: hard coded prach samples length
-    db_fulllength = PRACH_NUM_SAMPLES;
-
-    AssertFatal(rxF!=NULL,"rxF is null\n");
-
-    if (eth->flags == ETH_RAW_IF4p5_MODE) {		
-      memcpy(rxF, 
-             (int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t), 
-             PRACH_BLOCK_SIZE_BYTES);
-    } else {
-      memcpy(rxF,
-             (int16_t*) (rx_buffer+sizeof_IF4p5_header_t),
-             PRACH_BLOCK_SIZE_BYTES);
+      db_fulllength = PRACH_NUM_SAMPLES;
+
+      AssertFatal(rxF!=NULL,"rxF is null\n");
+
+      if (eth->flags == ETH_RAW_IF4p5_MODE) {		
+        memcpy(rxF, 
+               (int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t)+PRACH_BLOCK_SIZE_BYTES*antenna_id, 
+               PRACH_BLOCK_SIZE_BYTES);
+      } else {
+        memcpy(rxF,
+               (int16_t*) (rx_buffer+sizeof_IF4p5_header_t)+PRACH_BLOCK_SIZE_BYTES*antenna_id,
+               PRACH_BLOCK_SIZE_BYTES);
+      }
     }
-
     LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe,
 	  dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839)));
     for (idx=0;idx<ru->num_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe);
@@ -449,21 +467,21 @@ void malloc_IF4p5_buffer(RU_t *ru) {
 
   if (eth->flags == ETH_RAW_IF4p5_MODE) {
     for (i=0;i<10;i++) {
-      ru->ifbuffer.tx[i]       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
-      memset((void*)ru->ifbuffer.tx[i],0,RAW_IF4p5_PRACH_SIZE_BYTES);
+      ru->ifbuffer.tx[i]       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_tx);
+      memset((void*)ru->ifbuffer.tx[i],0,RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_tx);
     }
-    ru->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
-    memset((void*)ru->ifbuffer.tx_prach,0,RAW_IF4p5_PRACH_SIZE_BYTES);
-    ru->ifbuffer.rx       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); 
-    memset((void*)ru->ifbuffer.rx,0,RAW_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
+    memset((void*)ru->ifbuffer.tx_prach,0,RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
+    ru->ifbuffer.rx       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx); 
+    memset((void*)ru->ifbuffer.rx,0,RAW_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
   } else {
     for (i=0;i<10;i++) {
-      ru->ifbuffer.tx[i]       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
-      memset((void*)ru->ifbuffer.tx[i],0,UDP_IF4p5_PRACH_SIZE_BYTES);
+      ru->ifbuffer.tx[i]       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_tx);
+      memset((void*)ru->ifbuffer.tx[i],0,UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_tx);
     }
-    ru->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
-    memset((void*)ru->ifbuffer.tx_prach,0,UDP_IF4p5_PRACH_SIZE_BYTES);
-    ru->ifbuffer.rx       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
-    memset((void*)ru->ifbuffer.rx,0,UDP_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
+    memset((void*)ru->ifbuffer.tx_prach,0,UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
+    ru->ifbuffer.rx       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
+    memset((void*)ru->ifbuffer.rx,0,UDP_IF4p5_PRACH_SIZE_BYTES*ru->nb_rx);
   }
 }
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
index 129ec39357f..49fbcbf61fe 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
@@ -74,9 +74,9 @@ eNBs =
       srs_ackNackST                                      =;
       srs_MaxUpPts                                       =;*/
 
-      pusch_p0_Nominal                                   = -96;
+      pusch_p0_Nominal                                   = -104;
       pusch_alpha                                        = "AL1";
-      pucch_p0_Nominal                                   = -104;
+      pucch_p0_Nominal                                   = -108;
       msg3_delta_Preamble                                = 6;
       pucch_deltaF_Format1                               = "deltaF2";
       pucch_deltaF_Format1b                              = "deltaF3";
@@ -188,8 +188,8 @@ RUs = (
     	remote_portd   = 50001;
 	local_rf       = "no"
     	tr_preference  = "udp_if4p5"
-	nb_tx          = 1
-	nb_rx          = 1
+	nb_tx          = 2
+	nb_rx          = 2
 	att_tx         = 0
 	att_rx         = 0;
 	eNB_instances  = [0];
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 4bc1058b9af..4dd9ac79d44 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1300,7 +1300,7 @@ void wakeup_eNBs(RU_t *ru) {
     if (proc->RU_mask[ru->proc.subframe_rx] == (1<<eNB->num_RU)-1) {
       proc->RU_mask[ru->proc.subframe_rx] = 0;
       clock_gettime(CLOCK_MONOTONIC,&t);
-      AssertFatal(t.tv_nsec < proc->t[ru->proc.subframe_rx].tv_nsec+500000,
+      AssertFatal(t.tv_nsec < proc->t[ru->proc.subframe_rx].tv_nsec+5000000,
                   "Time difference for subframe %d => %d > 5ms\n",
                   ru->proc.subframe_rx,t.tv_nsec - proc->t[ru->proc.subframe_rx].tv_nsec);
     }
-- 
GitLab