Commit 19922715 authored by Sandeep Kumar's avatar Sandeep Kumar

rcc recv and send work (not sync with rru yet)

parent 808494dd
...@@ -193,22 +193,21 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type, ...@@ -193,22 +193,21 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
} }
db_halflength = db_fulllength>>1; db_halflength = db_fulllength>>1;
int64_t *ret_type=(int64_t*)malloc(sizeof(int64_t));
void *rx_buffer=NULL; void *rx_buffer=NULL;
IF4_header_t *packet_header=NULL;
int16_t *data_block=NULL; int16_t *data_block=NULL;
// Read packet(s) from the fronthaul // Read packet(s) from the fronthaul
if (eNB->ifdevice.trx_read_func(&eNB->ifdevice, if (eNB->ifdevice.trx_read_func(&eNB->ifdevice,
ret_type, (int64_t*) packet_type,
&rx_buffer, &rx_buffer,
db_fulllength, db_fulllength,
0) < 0) { 0) < 0) {
perror("ETHERNET read"); perror("ETHERNET read");
} }
*packet_type = (uint16_t) *ret_type; packet_header = (IF4_header_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES);
data_block = (int16_t*) (rx_buffer+sizeof_IF4_header_t); data_block = (int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4_header_t);
if (*packet_type == IF4_PDLFFT) { if (*packet_type == IF4_PDLFFT) {
// Calculate from received packet // Calculate from received packet
...@@ -225,7 +224,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type, ...@@ -225,7 +224,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
} }
// Find and return symbol_number // Find and return symbol_number
*symbol_number = ((((IF4_header_t*)(rx_buffer))->frame_status)>>26)&0x000f; *symbol_number = ((packet_header->frame_status)>>26)&0x000f;
} else if (*packet_type == IF4_PULFFT) { } else if (*packet_type == IF4_PULFFT) {
// Calculate from received packet // Calculate from received packet
...@@ -242,7 +241,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type, ...@@ -242,7 +241,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
} }
// Find and return symbol_number // Find and return symbol_number
*symbol_number = ((((IF4_header_t*)(rx_buffer))->frame_status)>>26)&0x000f; *symbol_number = ((packet_header->frame_status)>>26)&0x000f;
} else if (*packet_type == IF4_PRACH) { } else if (*packet_type == IF4_PRACH) {
// FIX: hard coded prach samples length // FIX: hard coded prach samples length
......
...@@ -312,13 +312,12 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp, ...@@ -312,13 +312,12 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t; ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t;
void *test_buffer = (void*)malloc(packet_size); void *test_buffer = (void*)malloc(packet_size);
void *rx_buffer=NULL;
IF4_header_t *test_header = (IF4_header_t*)(test_buffer + MAC_HEADER_SIZE_BYTES); IF4_header_t *test_header = (IF4_header_t*)(test_buffer + MAC_HEADER_SIZE_BYTES);
bytes_received = recv(eth->sockfd[Mod_id], bytes_received = recv(eth->sockfd[Mod_id],
test_buffer, test_buffer,
packet_size, packet_size,
0); MSG_PEEK);
if (bytes_received ==-1) { if (bytes_received ==-1) {
eth->num_rx_errors++; eth->num_rx_errors++;
perror("ETHERNET READ: "); perror("ETHERNET READ: ");
...@@ -328,29 +327,22 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp, ...@@ -328,29 +327,22 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
*timestamp = test_header->sub_type; *timestamp = test_header->sub_type;
if (test_header->sub_type == IF4_PDLFFT) { if (test_header->sub_type == IF4_PDLFFT) {
buff[0] = (void*)malloc(RAW_IF4_PDLFFT_SIZE_BYTES(nblocks) - MAC_HEADER_SIZE_BYTES); packet_size = RAW_IF4_PDLFFT_SIZE_BYTES(nblocks);
packet_size = RAW_IF4_PDLFFT_SIZE_BYTES(nblocks) - packet_size;
} else if (test_header->sub_type == IF4_PULFFT) { } else if (test_header->sub_type == IF4_PULFFT) {
buff[0] = (void*)malloc(RAW_IF4_PULFFT_SIZE_BYTES(nblocks) - MAC_HEADER_SIZE_BYTES); packet_size = RAW_IF4_PULFFT_SIZE_BYTES(nblocks);
packet_size = RAW_IF4_PULFFT_SIZE_BYTES(nblocks) - packet_size;
} else { } else {
buff[0] = (void*)malloc(RAW_IF4_PRACH_SIZE_BYTES - MAC_HEADER_SIZE_BYTES); packet_size = RAW_IF4_PRACH_SIZE_BYTES;
packet_size = RAW_IF4_PRACH_SIZE_BYTES - packet_size;
printf(" Came for prach\n");
} }
memcpy(buff[0], test_header, sizeof_IF4_header_t); buff[0] = (void*)malloc(packet_size);
rx_buffer = (void*)(buff[0]+sizeof_IF4_header_t);
bytes_received = 0; bytes_received = 0;
while(bytes_received < packet_size) { while(bytes_received < packet_size) {
bytes_received += recv(eth->sockfd[Mod_id], bytes_received = recv(eth->sockfd[Mod_id],
rx_buffer, buff[0],
packet_size-bytes_received, packet_size,
0); 0);
if (bytes_received ==-1) { if (bytes_received ==-1) {
eth->num_rx_errors++; eth->num_rx_errors++;
perror("ETHERNET READ: "); perror("ETHERNET READ: ");
...@@ -361,10 +353,9 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp, ...@@ -361,10 +353,9 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
} }
} }
eth->rx_nsamps = nsamps; eth->rx_nsamps = nsamps;
free(test_buffer); free(test_buffer);
return (bytes_received-MAC_HEADER_SIZE_BYTES)>>1; return(bytes_received);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment