Skip to content
Snippets Groups Projects
Commit 08499a69 authored by luhan wang's avatar luhan wang
Browse files

modifications for IF4p5 UDP transport

parent 25ab1c35
Branches
Tags
No related merge requests found
......@@ -41,7 +41,8 @@
#include "PHY/defs.h"
#include "PHY/TOOLS/alaw_lut.h"
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
//#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type, int k) {
......@@ -57,6 +58,9 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
uint16_t *data_block=NULL, *i=NULL;
IF4p5_header_t *packet_header=NULL;
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
if (packet_type == IF4p5_PDLFFT) {
......@@ -65,10 +69,14 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
IF4p5_header_t *dl_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
gen_IF4p5_dl_header(dl_header, frame, subframe);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer);
data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
}
gen_IF4p5_dl_header(packet_header, frame, subframe);
for (symbol_id=0; symbol_id<fp->symbols_per_tti; symbol_id++) {
......@@ -80,8 +88,8 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
}
dl_header->frame_status &= ~(0x000f<<26);
dl_header->frame_status |= (symbol_id&0x000f)<<26;
packet_header->frame_status &= ~(0x000f<<26);
packet_header->frame_status |= (symbol_id&0x000f)<<26;
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
......@@ -101,10 +109,14 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
slotoffsetF = 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
IF4p5_header_t *ul_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
gen_IF4p5_ul_header(ul_header, frame, subframe);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer);
data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
}
gen_IF4p5_ul_header(packet_header, frame, subframe);
for (symbol_id=0; symbol_id<fp->symbols_per_tti; symbol_id++) {
......@@ -116,8 +128,8 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
}
ul_header->frame_status &= ~(0x000f<<26);
ul_header->frame_status |= (symbol_id&0x000f)<<26;
packet_header->frame_status &= ~(0x000f<<26);
packet_header->frame_status |= (symbol_id&0x000f)<<26;
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
......@@ -134,15 +146,24 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
} else if (packet_type == IF4p5_PRACH) {
// FIX: hard coded prach samples length
db_fulllength = 840*2;
IF4p5_header_t *prach_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer);
data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
}
gen_IF4p5_prach_header(packet_header, frame, subframe);
gen_IF4p5_prach_header(prach_header, frame, subframe);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
(&rxsigF[0][k]),
db_fulllength*sizeof(int16_t));
} else {
memcpy((int16_t*)(tx_buffer + sizeof_IF4p5_header_t),
(&rxsigF[0][k]),
db_fulllength*sizeof(int16_t));
}
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
......@@ -171,6 +192,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
uint16_t element_id;
uint16_t db_fulllength, db_halflength;
int slotoffsetF=0, blockoffsetF=0;
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );
......@@ -192,11 +214,17 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
perror("ETHERNET read");
}
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t*) (rx_buffer);
data_block = (uint16_t*) (rx_buffer+sizeof_IF4p5_header_t);
}
*frame = ((packet_header->frame_status)>>6)&0xffff;
*subframe = ((packet_header->frame_status)>>22)&0x000f;
*packet_type = packet_header->sub_type;
if (*packet_type == IF4p5_PDLFFT) {
......@@ -235,9 +263,15 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
// FIX: hard coded prach samples length
db_fulllength = 840*2;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t),
db_fulllength*sizeof(int16_t));
} else {
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+sizeof_IF4p5_header_t),
db_fulllength*sizeof(int16_t));
}
} else {
AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type);
......@@ -290,6 +324,12 @@ void gen_IF4p5_prach_header(IF4p5_header_t *prach_packet, int frame, int subfram
void malloc_IF4p5_buffer(PHY_VARS_eNB *eNB) {
// Keep the size large enough
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
eNB->ifbuffer.tx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
} else {
eNB->ifbuffer.tx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment