Merge branch 'develop' into RU-RAU-split
Conflicts: openair1/PHY/INIT/lte_init.c openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c openair1/PHY/LTE_TRANSPORT/dci.c openair1/PHY/LTE_TRANSPORT/dci_tools.c openair1/PHY/LTE_TRANSPORT/dlsch_coding.c openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c openair1/PHY/LTE_TRANSPORT/if4_tools.c openair1/PHY/LTE_TRANSPORT/if5_tools.c openair1/PHY/LTE_TRANSPORT/if5_tools.h openair1/PHY/LTE_TRANSPORT/pcfich.c openair1/PHY/LTE_TRANSPORT/phich.c openair1/PHY/LTE_TRANSPORT/prach.c openair1/PHY/LTE_TRANSPORT/rar_tools.c openair1/PHY/LTE_TRANSPORT/srs_modulation.c openair1/PHY/defs.h openair1/PHY/impl_defs_lte.h openair1/PHY/impl_defs_top.h openair1/SCHED/phy_procedures_lte_eNb.c openair1/SCHED/phy_procedures_lte_ue.c openair2/COMMON/mac_rrc_primitives.h openair2/ENB_APP/enb_config.c openair2/ENB_APP/enb_config.h openair2/LAYER2/MAC/config.c openair2/LAYER2/MAC/eNB_scheduler.c openair2/LAYER2/MAC/eNB_scheduler_dlsch.c openair2/LAYER2/MAC/eNB_scheduler_mch.c openair2/LAYER2/MAC/eNB_scheduler_primitives.c openair2/LAYER2/MAC/main.c openair2/LAYER2/MAC/proto.h openair2/RRC/LITE/MESSAGES/asn1_msg.c openair2/RRC/LITE/MESSAGES/asn1_msg.h openair2/RRC/LITE/rrc_UE.c openair2/RRC/LITE/rrc_common.c openair2/RRC/LITE/rrc_eNB.c targets/ARCH/COMMON/common_lib.c targets/ARCH/COMMON/common_lib.h targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf targets/RT/USER/lte-enb.c targets/RT/USER/lte-softmodem.c targets/RT/USER/lte-ue.c targets/RT/USER/rt_wrapper.h targets/SIMU/USER/channel_sim.c targets/SIMU/USER/init_lte.c targets/SIMU/USER/oaisim.c targets/SIMU/USER/oaisim_functions.c
This commit is contained in:
@@ -163,21 +163,25 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
|
||||
memcpy(buff2,(void*)ð->ehd,MAC_HEADER_SIZE_BYTES);
|
||||
*(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t))=1+(i<<1);
|
||||
*(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = timestamp;
|
||||
|
||||
int sent_byte;
|
||||
|
||||
|
||||
/*printf("[RRU]write mod_%d %d , len %d, buff %p \n",
|
||||
Mod_id,eth->sockfd[Mod_id],RAW_PACKET_SIZE_BYTES(nsamps), buff2);*/
|
||||
|
||||
while(bytes_sent < RAW_PACKET_SIZE_BYTES(nsamps)) {
|
||||
while(bytes_sent < sent_byte) {
|
||||
#if DEBUG
|
||||
printf("------- TX ------: buff2 current position=%d remaining_bytes=%d bytes_sent=%d \n",
|
||||
(void *)(buff2+bytes_sent),
|
||||
RAW_PACKET_SIZE_BYTES(nsamps) - bytes_sent,
|
||||
sent_byte - bytes_sent,
|
||||
bytes_sent);
|
||||
#endif
|
||||
/* Send packet */
|
||||
|
||||
bytes_sent += send(eth->sockfdd,
|
||||
buff2,
|
||||
RAW_PACKET_SIZE_BYTES(nsamps),
|
||||
sent_byte,
|
||||
sendto_flag);
|
||||
if ( bytes_sent == -1) {
|
||||
eth->num_tx_errors++;
|
||||
@@ -190,7 +194,9 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
|
||||
*(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)),
|
||||
*(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)),
|
||||
bytes_sent);
|
||||
dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, RAW_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
|
||||
|
||||
dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, sent_byte, TX_FLAG);
|
||||
|
||||
#endif
|
||||
eth->tx_actual_nsamps=bytes_sent>>2;
|
||||
eth->tx_count++;
|
||||
@@ -253,39 +259,73 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam
|
||||
|
||||
|
||||
int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) {
|
||||
|
||||
|
||||
int ret;
|
||||
int bytes_received=0;
|
||||
int i=0;
|
||||
eth_state_t *eth = (eth_state_t*)device->priv;
|
||||
int rcvfrom_flag =0;
|
||||
int ret;
|
||||
|
||||
int block_cnt=0;
|
||||
int again_cnt=0;
|
||||
|
||||
eth->rx_nsamps=nsamps;
|
||||
|
||||
for (i=0;i<cc;i++) {
|
||||
/* buff[i] points to the position in rx buffer where the payload to be received will be placed
|
||||
buff2 points to the position in rx buffer where the packet header will be placed */
|
||||
void *buff2 = (void*)(buff[i]-APP_HEADER_SIZE_BYTES-MAC_HEADER_SIZE_BYTES);
|
||||
|
||||
|
||||
/* we don't want to ovewrite with the header info the previous rx buffer data so we store it*/
|
||||
struct ether_header temp = *(struct ether_header *)buff2;
|
||||
int32_t temp0 = *(int32_t *)(buff2 + MAC_HEADER_SIZE_BYTES);
|
||||
openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t));
|
||||
|
||||
|
||||
bytes_received=0;
|
||||
int receive_bytes;
|
||||
if (eth->compression == ALAW_COMPRESS) {
|
||||
receive_bytes = RAW_PACKET_SIZE_BYTES_ALAW(nsamps);
|
||||
} else {
|
||||
receive_bytes = RAW_PACKET_SIZE_BYTES(nsamps);
|
||||
}
|
||||
|
||||
while(bytes_received < RAW_PACKET_SIZE_BYTES(nsamps)) {
|
||||
while(bytes_received < receive_bytes) {
|
||||
again:
|
||||
ret = recv(eth->sockfdd,
|
||||
buff2,
|
||||
RAW_PACKET_SIZE_BYTES(nsamps),
|
||||
rcvfrom_flag);
|
||||
|
||||
buff2,
|
||||
receive_bytes,
|
||||
rcvfrom_flag);
|
||||
|
||||
if (ret ==-1) {
|
||||
eth->num_rx_errors++;
|
||||
perror("ETHERNET IF5 READ: ");
|
||||
return(-1);
|
||||
if (errno == EAGAIN) {
|
||||
again_cnt++;
|
||||
usleep(10);
|
||||
if (again_cnt == 1000) {
|
||||
perror("ETHERNET IF5 READ (EAGAIN): ");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN \n");
|
||||
goto again;
|
||||
}
|
||||
} else if (errno == EWOULDBLOCK) {
|
||||
block_cnt++;
|
||||
usleep(10);
|
||||
if (block_cnt == 1000) {
|
||||
perror("ETHERNET IF5 READ (EWOULDBLOCK): ");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n");
|
||||
goto again;
|
||||
}
|
||||
} else {
|
||||
perror("ETHERNET IF5 READ");
|
||||
printf("(%s):\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
} else {
|
||||
bytes_received += ret;
|
||||
bytes_received+=ret;
|
||||
/* store the timestamp value from packet's header */
|
||||
*timestamp = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t));
|
||||
eth->rx_actual_nsamps=bytes_received>>2;
|
||||
@@ -299,6 +339,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
|
||||
*(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)),
|
||||
*(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)),
|
||||
bytes_received);
|
||||
|
||||
dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, RAW_PACKET_SIZE_BYTES(nsamps),RX_FLAG);
|
||||
|
||||
#endif
|
||||
@@ -315,6 +356,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
|
||||
|
||||
int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) {
|
||||
|
||||
int ret;
|
||||
// Read nblocks info from packet itself
|
||||
int nblocks = nsamps;
|
||||
int bytes_received=0;
|
||||
@@ -322,26 +364,53 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
|
||||
|
||||
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t;
|
||||
IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0] + MAC_HEADER_SIZE_BYTES);
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Reading from device %p, eth %p, sockfd %d\n",device,eth,eth->sockfd);
|
||||
#endif
|
||||
int block_cnt=0;
|
||||
int again_cnt=0;
|
||||
|
||||
bytes_received = recv(eth->sockfdd,
|
||||
buff[0],
|
||||
packet_size,
|
||||
MSG_PEEK);
|
||||
if (bytes_received ==-1) {
|
||||
eth->num_rx_errors++;
|
||||
perror("ETHERNET IF4p5 READ (header): ");
|
||||
#ifdef DEBUG
|
||||
for (int i=0;i<packet_size;i++)
|
||||
printf("%2x.",((uint8_t*)buff[0])[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
return(-1);
|
||||
while (bytes_received < packet_size) {
|
||||
again:
|
||||
ret = recv(eth->sockfdd,
|
||||
buff[0],
|
||||
packet_size,
|
||||
MSG_PEEK);
|
||||
if (ret ==-1) {
|
||||
eth->num_rx_errors++;
|
||||
if (errno == EAGAIN) {
|
||||
again_cnt++;
|
||||
usleep(10);
|
||||
if (again_cnt == 1000) {
|
||||
perror("ETHERNET IF4p5 READ (EAGAIN): ");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN \n");
|
||||
goto again;
|
||||
}
|
||||
} else if (errno == EWOULDBLOCK) {
|
||||
block_cnt++;
|
||||
usleep(10);
|
||||
if (block_cnt == 1000) {
|
||||
perror("ETHERNET IF4p5 READ (EWOULDBLOCK): ");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n");
|
||||
goto again;
|
||||
}
|
||||
} else {
|
||||
perror("ETHERNET IF4p5 READ");
|
||||
printf("(%s):\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else bytes_received+=ret;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (int i=0;i<packet_size;i++)
|
||||
printf("%2x.",((uint8_t*)buff[0])[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
*timestamp = test_header->sub_type;
|
||||
|
||||
if (test_header->sub_type == IF4p5_PDLFFT) {
|
||||
@@ -350,8 +419,7 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
|
||||
packet_size = RAW_IF4p5_PULFFT_SIZE_BYTES(nblocks);
|
||||
} else {
|
||||
packet_size = RAW_IF4p5_PRACH_SIZE_BYTES;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while(bytes_received < packet_size) {
|
||||
ret = recv(eth->sockfdd,
|
||||
|
||||
@@ -289,23 +289,30 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
|
||||
// eth->pck_header.seq_num = pck_seq_num;
|
||||
//eth->pck_header.antenna_id = 1+(i<<1);
|
||||
//eth->pck_header.timestamp = timestamp;
|
||||
*(uint16_t *)buff2 = pck_seq_num;
|
||||
*(uint16_t *)buff2 = eth->pck_seq_num;
|
||||
*(uint16_t *)(buff2 + sizeof(uint16_t)) = 1+(i<<1);
|
||||
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = timestamp;
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TX_SEQ_NUM, pck_seq_num);
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TX_SEQ_NUM, eth->pck_seq_num);
|
||||
|
||||
|
||||
while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) {
|
||||
int sent_byte;
|
||||
if (eth->compression == ALAW_COMPRESS) {
|
||||
sent_byte = UDP_PACKET_SIZE_BYTES_ALAW(nsamps);
|
||||
} else {
|
||||
sent_byte = UDP_PACKET_SIZE_BYTES(nsamps);
|
||||
}
|
||||
|
||||
//while(bytes_sent < sent_byte) {
|
||||
//printf("eth->pck_seq_num: %d\n", eth->pck_seq_num);
|
||||
#if DEBUG
|
||||
printf("------- TX ------: buff2 current position=%d remaining_bytes=%d bytes_sent=%d \n",
|
||||
(void *)(buff2+bytes_sent),
|
||||
UDP_PACKET_SIZE_BYTES(nsamps) - bytes_sent,
|
||||
sent_byte - bytes_sent,
|
||||
bytes_sent);
|
||||
#endif
|
||||
/* Send packet */
|
||||
bytes_sent += sendto(eth->sockfdd,
|
||||
buff2,
|
||||
UDP_PACKET_SIZE_BYTES(nsamps),
|
||||
sent_byte,
|
||||
sendto_flag,
|
||||
(struct sockaddr*)ð->dest_addrd,
|
||||
eth->addr_len);
|
||||
@@ -321,14 +328,16 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
|
||||
*(int16_t *)(buff2 + sizeof(int16_t)),
|
||||
*(openair0_timestamp *)(buff2 + sizeof(int32_t)),
|
||||
bytes_sent);
|
||||
|
||||
dump_packet((device->host_type == RAU_HOST)? "RAU":"RAU", buff2, UDP_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
|
||||
#endif
|
||||
eth->tx_actual_nsamps=bytes_sent>>2;
|
||||
eth->tx_count++;
|
||||
pck_seq_num++;
|
||||
if ( pck_seq_num > MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame) ) pck_seq_num = 1;
|
||||
eth->pck_seq_num++;
|
||||
if ( eth->pck_seq_num > MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame) ) eth->pck_seq_num = 1;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
/* tx buffer values restored */
|
||||
*(int32_t *)buff2 = temp0;
|
||||
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1;
|
||||
@@ -362,19 +371,24 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
|
||||
|
||||
bytes_received=0;
|
||||
block_cnt=0;
|
||||
int receive_bytes;
|
||||
if (eth->compression == ALAW_COMPRESS) {
|
||||
receive_bytes = UDP_PACKET_SIZE_BYTES_ALAW(nsamps);
|
||||
} else {
|
||||
receive_bytes = UDP_PACKET_SIZE_BYTES(nsamps);
|
||||
}
|
||||
|
||||
|
||||
while(bytes_received < UDP_PACKET_SIZE_BYTES(nsamps)) {
|
||||
while(bytes_received < receive_bytes) {
|
||||
again:
|
||||
#if DEBUG
|
||||
printf("------- RX------: buff2 current position=%d remaining_bytes=%d bytes_recv=%d \n",
|
||||
(void *)(buff2+bytes_received),
|
||||
UDP_PACKET_SIZE_BYTES(nsamps) - bytes_received,
|
||||
receive_bytes - bytes_received,
|
||||
bytes_received);
|
||||
#endif
|
||||
bytes_received +=recvfrom(eth->sockfdd,
|
||||
buff2,
|
||||
UDP_PACKET_SIZE_BYTES(nsamps),
|
||||
receive_bytes,
|
||||
rcvfrom_flag,
|
||||
(struct sockaddr *)ð->dest_addrd,
|
||||
(socklen_t *)ð->addr_len);
|
||||
@@ -409,28 +423,30 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
|
||||
*(int16_t *)(buff2 + sizeof(int16_t)),
|
||||
*(openair0_timestamp *)(buff2 + sizeof(int32_t)),
|
||||
bytes_received);
|
||||
|
||||
dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, UDP_PACKET_SIZE_BYTES(nsamps),RX_FLAG);
|
||||
#endif
|
||||
|
||||
/* store the timestamp value from packet's header */
|
||||
*timestamp = *(openair0_timestamp *)(buff2 + sizeof(int32_t));
|
||||
/* store the sequence number of the previous packet received */
|
||||
if (pck_seq_num_cur == 0) {
|
||||
pck_seq_num_prev = *(uint16_t *)buff2;
|
||||
if (eth->pck_seq_num_cur == 0) {
|
||||
eth->pck_seq_num_prev = *(uint16_t *)buff2;
|
||||
} else {
|
||||
pck_seq_num_prev = pck_seq_num_cur;
|
||||
eth->pck_seq_num_prev = eth->pck_seq_num_cur;
|
||||
}
|
||||
/* get the packet sequence number from packet's header */
|
||||
pck_seq_num_cur = *(uint16_t *)buff2;
|
||||
//printf("cur=%d prev=%d buff=%d\n",pck_seq_num_cur,pck_seq_num_prev,*(uint16_t *)(buff2));
|
||||
if ( ( pck_seq_num_cur != (pck_seq_num_prev + 1) ) && !((pck_seq_num_prev==MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame)) && (pck_seq_num_cur==1 )) && !((pck_seq_num_prev==1) && (pck_seq_num_cur==1))) {
|
||||
printf("out of order packet received1! %d|%d|%d\n",pck_seq_num_cur,pck_seq_num_prev,(int)*timestamp);
|
||||
eth->pck_seq_num_cur = *(uint16_t *)buff2;
|
||||
if ( ( eth->pck_seq_num_cur != (eth->pck_seq_num_prev + 1) ) && !((eth->pck_seq_num_prev==MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame)) && (eth->pck_seq_num_cur==1 )) && !((eth->pck_seq_num_prev==1) && (eth->pck_seq_num_cur==1))) {
|
||||
//#if DEBUG
|
||||
printf("Out of order packet received: current_packet=%d previous_packet=%d timestamp=%"PRId64"\n",eth->pck_seq_num_cur,eth->pck_seq_num_prev,*timestamp);
|
||||
//#endif
|
||||
}
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM,pck_seq_num_cur);
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM_PRV,pck_seq_num_prev);
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM,eth->pck_seq_num_cur);
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM_PRV,eth->pck_seq_num_prev);
|
||||
eth->rx_actual_nsamps=bytes_received>>2;
|
||||
eth->rx_count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* tx buffer values restored */
|
||||
@@ -442,6 +458,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
|
||||
}
|
||||
|
||||
|
||||
|
||||
int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len) {
|
||||
|
||||
return(sendto(((eth_state_t*)device->priv)->sockfdc,
|
||||
|
||||
@@ -41,16 +41,24 @@
|
||||
#include <netinet/ether.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include "common_lib.h"
|
||||
#include "ethernet_lib.h"
|
||||
|
||||
|
||||
int num_devices_eth = 0;
|
||||
struct sockaddr_in dest_addr[MAX_INST];
|
||||
int dest_addr_len[MAX_INST];
|
||||
|
||||
|
||||
int trx_eth_start(openair0_device *device) {
|
||||
|
||||
eth_state_t *eth = (eth_state_t*)device->priv;
|
||||
|
||||
/* initialize socket */
|
||||
if (eth->flags == ETH_RAW_MODE) {
|
||||
if (eth->flags == ETH_RAW_MODE) {
|
||||
printf("Setting ETHERNET to ETH_RAW_IF5_MODE\n");
|
||||
if (eth_socket_init_raw(device)!=0) return -1;
|
||||
/* RRU gets device configuration - RAU sets device configuration*/
|
||||
@@ -66,10 +74,14 @@ int trx_eth_start(openair0_device *device) {
|
||||
}*/
|
||||
|
||||
/* adjust MTU wrt number of samples per packet */
|
||||
if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1;
|
||||
if(eth->compression == ALAW_COMPRESS) {
|
||||
if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES_ALAW(device->openair0_cfg->samples_per_packet))!=0) return -1;
|
||||
} else {
|
||||
if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1;
|
||||
}
|
||||
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
|
||||
} else if (eth->flags == ETH_RAW_IF4p5_MODE) {
|
||||
|
||||
|
||||
printf("Setting ETHERNET to ETH_RAW_IF4p5_MODE\n");
|
||||
if (eth_socket_init_raw(device)!=0) return -1;
|
||||
|
||||
@@ -86,6 +98,7 @@ int trx_eth_start(openair0_device *device) {
|
||||
|
||||
/* adjust MTU wrt number of samples per packet */
|
||||
if(ethernet_tune (device,MTU_SIZE,RAW_IF4p5_PRACH_SIZE_BYTES)!=0) return -1;
|
||||
|
||||
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
|
||||
} else if (eth->flags == ETH_UDP_IF4p5_MODE) {
|
||||
printf("Setting ETHERNET to UDP_IF4p5_MODE\n");
|
||||
@@ -132,7 +145,9 @@ int trx_eth_start(openair0_device *device) {
|
||||
/* apply additional configuration */
|
||||
if(ethernet_tune (device, SND_BUF_SIZE,2000000000)!=0) return -1;
|
||||
if(ethernet_tune (device, RCV_BUF_SIZE,2000000000)!=0) return -1;
|
||||
|
||||
if(ethernet_tune (device, KERNEL_SND_BUF_MAX_SIZE, 200000000)!=0) return -1;
|
||||
if(ethernet_tune (device, KERNEL_RCV_BUF_MAX_SIZE, 200000000)!=0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -176,10 +191,12 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
|
||||
eth_state_t *eth = (eth_state_t*)device->priv;
|
||||
struct timeval timeout;
|
||||
struct ifreq ifr;
|
||||
char system_cmd[256];
|
||||
// char* if_name=DEFAULT_IF;
|
||||
// struct in_addr ia;
|
||||
// struct if_nameindex *ids;
|
||||
char system_cmd[256];
|
||||
int rname[] = { CTL_NET, NET_CORE, NET_CORE_RMEM_MAX };
|
||||
int wname[] = { CTL_NET, NET_CORE, NET_CORE_WMEM_MAX };
|
||||
int namelen=3;
|
||||
int newval[1];
|
||||
int newlen=sizeof(newval);
|
||||
int ret=0;
|
||||
// int i=0;
|
||||
|
||||
@@ -279,7 +296,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
|
||||
if (ret == -1) {
|
||||
fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno));
|
||||
} else {
|
||||
printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret));
|
||||
printf ("[ETHERNET] status of %s is %d\n", system_cmd, WEXITSTATUS(ret));
|
||||
}
|
||||
printf("[ETHERNET] Coalesce parameters %s\n",system_cmd);
|
||||
} else {
|
||||
@@ -296,7 +313,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
|
||||
if (ret == -1) {
|
||||
fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno));
|
||||
} else {
|
||||
printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret));
|
||||
printf ("[ETHERNET] status of %s is %d\n", system_cmd, WEXITSTATUS(ret));
|
||||
}
|
||||
printf("[ETHERNET] Pause parameters %s\n",system_cmd);
|
||||
} else {
|
||||
@@ -311,14 +328,32 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
|
||||
if (ret == -1) {
|
||||
fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno));
|
||||
} else {
|
||||
printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret));
|
||||
printf ("[ETHERNET] status of %s is %d\n", system_cmd, WEXITSTATUS(ret));
|
||||
}
|
||||
printf("[ETHERNET] Ring parameters %s\n",system_cmd);
|
||||
} else {
|
||||
perror("[ETHERNET] Can't set ring parameters\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case KERNEL_RCV_BUF_MAX_SIZE:
|
||||
newval[0] = value;
|
||||
ret=sysctl(rname, namelen, NULL, 0, newval, newlen);
|
||||
if (ret) {
|
||||
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
|
||||
} else{
|
||||
printf("[ETHERNET] Kernel network receive buffer max size is set to %u\n",newval[0]);
|
||||
}
|
||||
break;
|
||||
case KERNEL_SND_BUF_MAX_SIZE:
|
||||
newval[0] = value;
|
||||
ret=sysctl(wname, namelen, NULL, 0, newval, newlen);
|
||||
if (ret) {
|
||||
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
|
||||
} else{
|
||||
printf("[ETHERNET] Kernel network send buffer max size is set to %u\n",newval[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -346,6 +381,15 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
|
||||
printf("transport_init: Unknown transport preference %d - default to RAW", eth_params->transp_preference);
|
||||
eth->flags = ETH_RAW_MODE;
|
||||
}
|
||||
|
||||
if (eth_params->if_compress == 0) {
|
||||
eth->compression = NO_COMPRESS;
|
||||
} else if (eth_params->if_compress == 1) {
|
||||
eth->compression = ALAW_COMPRESS;
|
||||
} else {
|
||||
printf("transport_init: Unknown compression scheme %d - default to ALAW", eth_params->if_compress);
|
||||
eth->compression = ALAW_COMPRESS;
|
||||
}
|
||||
|
||||
printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
||||
device->Mod_id = 0;//num_devices_eth++;
|
||||
|
||||
@@ -88,6 +88,8 @@ typedef struct {
|
||||
unsigned int tx_timeout_ms;
|
||||
/*!\brief runtime flags */
|
||||
uint32_t flags;
|
||||
/*!\compression enalbe */
|
||||
uint32_t compression;
|
||||
/*!\ time offset between transmiter timestamp and receiver timestamp */
|
||||
double tdiff;
|
||||
/*!\ calibration */
|
||||
@@ -108,7 +110,7 @@ typedef struct {
|
||||
int num_seq_errors;
|
||||
/*!\brief number of errors in interface's receiver */
|
||||
int num_rx_errors;
|
||||
/*!\brief umber of errors in interface's transmitter */
|
||||
/*!\brief number of errors in interface's transmitter */
|
||||
int num_tx_errors;
|
||||
|
||||
/*!\brief current TX timestamp */
|
||||
@@ -127,6 +129,12 @@ typedef struct {
|
||||
uint64_t tx_count;
|
||||
/*!\brief number of packets received */
|
||||
uint64_t rx_count;
|
||||
/*!\brief TX sequence number*/
|
||||
uint16_t pck_seq_num;
|
||||
/*!\brief Current RX sequence number*/
|
||||
uint16_t pck_seq_num_cur;
|
||||
/*!\brief Previous RX sequence number */
|
||||
uint16_t pck_seq_num_prev;
|
||||
/*!\brief precomputed ethernet header (control) */
|
||||
struct ether_header ehc;
|
||||
/*!\brief precomputed ethernet header (data) */
|
||||
@@ -166,6 +174,10 @@ typedef enum {
|
||||
COALESCE_PAR,
|
||||
/*!\brief pause parameters of ethernet device */
|
||||
PAUSE_PAR,
|
||||
/*!\brief kernel network receive buffer maximun size */
|
||||
KERNEL_RCV_BUF_MAX_SIZE,
|
||||
/*!\brief kernel network send buffer maximun size */
|
||||
KERNEL_SND_BUF_MAX_SIZE,
|
||||
MAX_OPT
|
||||
} eth_opt_t;
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
|
||||
// COMMOM HEADER LENGTHS
|
||||
|
||||
#define NO_COMPRESS 0
|
||||
#define ALAW_COMPRESS 1
|
||||
|
||||
#define UDP_HEADER_SIZE_BYTES 8
|
||||
#define IPV4_HEADER_SIZE_BYTES 60 // This is the maximum IPv4 header length
|
||||
|
||||
@@ -59,10 +62,14 @@
|
||||
#define UDP_PACKET_SIZE_BYTES(nsamps) (APP_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES(nsamps))
|
||||
#define RAW_PACKET_SIZE_BYTES(nsamps) (APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES(nsamps))
|
||||
|
||||
#define PAYLOAD_SIZE_BYTES_ALAW(nsamps) (nsamps<<1)
|
||||
#define UDP_PACKET_SIZE_BYTES_ALAW(nsamps) (APP_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES_ALAW(nsamps))
|
||||
#define RAW_PACKET_SIZE_BYTES_ALAW(nsamps) (APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES_ALAW(nsamps))
|
||||
|
||||
// Packet sizes for IF4p5 interface format
|
||||
#define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(uint16_t)*scaled_nblocks)
|
||||
#define PRACH_NUM_SAMPLES (839)
|
||||
#define PRACH_BLOCK_SIZE_BYTES (sizeof(int32_t)*PRACH_NUM_SAMPLES)
|
||||
#define PRACH_NUM_SAMPLES (839*2)
|
||||
#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*PRACH_NUM_SAMPLES)
|
||||
|
||||
#define RAW_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
|
||||
#define RAW_IF4p5_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
|
||||
|
||||
Reference in New Issue
Block a user