From 094f439626250f3dc5e28714a13d924f9083a2de Mon Sep 17 00:00:00 2001 From: luhan wang Date: Wed, 21 Sep 2016 09:18:31 +0200 Subject: [PATCH 01/59] comment in phy_procedures_lte_eNb.c --- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- .../CONF/rcc.band7.tm1.50PRB.if4p5.conf | 14 +++++++------- .../CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf | 6 +++--- targets/RT/USER/lte-enb.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 980fa3335a..18c986c39e 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1923,7 +1923,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) { eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits eNB->UE_stats[(uint32_t)UE_id].sector = 0; - LOG_D(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", + LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", eNB->Mod_id, eNB->CC_id, frame, diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf index b264993dd4..5fc097f0df 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; @@ -67,9 +67,9 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -90; + pusch_p0_Nominal = -102; pusch_alpha = "AL1"; - pucch_p0_Nominal = -96; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -85,7 +85,7 @@ eNBs = rach_messagePowerOffsetGroupB = ; */ rach_powerRampingStep = 4; - rach_preambleInitialReceivedTargetPower = -108; + rach_preambleInitialReceivedTargetPower = -104; rach_preambleTransMax = 10; rach_raResponseWindowSize = 10; rach_macContentionResolutionTimer = 48; @@ -155,9 +155,9 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth0"; - remote_address = "74:d4:35:cc:8d:15"; - local_address = "34:e6:d7:3c:ae:fc"; + local_if_name = "eth2"; + remote_address = "00:13:95:1f:a0:af"; + local_address = "90:e2:ba:c5:fc:04"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf index 4929f39b3b..edf698b077 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf @@ -155,9 +155,9 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth0"; - remote_address = "74:d4:35:cc:8d:15"; - local_address = "34:e6:d7:3c:ae:fc"; + local_if_name = "eth2"; + remote_address = "00:13:95:1f:a0:af"; + local_address = "90:e2:ba:c5:fc:04"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 9d4b0f1aeb..09901ccd88 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -191,7 +191,7 @@ static inline void thread_top_init(char *thread_name, exit_fun("Error setting deadline scheduler"); } - LOG_I( HW, "[SCHED] eNB %s deadline thread (TID %ld) started on CPU %d\n", gettid(), thread_name,sched_getcpu() ); + LOG_I( HW, "[SCHED] eNB %s deadline thread started on CPU %d\n", thread_name,sched_getcpu() ); #else //LOW_LATENCY int policy, s, j; From 8c37787e236f73a5fd9629fefa8f23dcb270cbca Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 19 Oct 2016 09:30:42 +0200 Subject: [PATCH 02/59] added 25 PRB rru file --- .../rru.band7.tm1.if4p5.25PRB.usrpb210.conf | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf new file mode 100644 index 0000000000..7806e917ac --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf @@ -0,0 +1,193 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RRU_IF4p5"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 120; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -29; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -95; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -104; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.11"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "eth0"; + remote_address = "90:e2:ba:c5:fc:04"; + local_address = "00:13:95:1f:a0:af"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "raw_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); From 25ab1c35ee43551d1fdec740a7aae0e361607d99 Mon Sep 17 00:00:00 2001 From: luhan wang Date: Thu, 20 Oct 2016 14:18:32 +0200 Subject: [PATCH 03/59] modifications for if4p5 UDP --- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 969 +++++++++--------- 1 file changed, 487 insertions(+), 482 deletions(-) diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index 11aa8ed9ba..7d5fecbbf2 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -1,482 +1,487 @@ -/******************************************************************************* - OpenAirInterface - Copyright(c) 1999 - 2014 Eurecom - - OpenAirInterface is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - - OpenAirInterface is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OpenAirInterface.The full GNU General Public License is - included in this distribution in the file called "COPYING". If not, - see . - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE - - *******************************************************************************/ -/*! \file ethernet_lib.c - * \brief API to stream I/Q samples over standard ethernet - * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp - * \date 2015 - * \version 0.2 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "vcd_signal_dumper.h" - -#include "common_lib.h" -#include "ethernet_lib.h" - -#define DEBUG 0 -struct sockaddr_in dest_addr[MAX_INST]; -struct sockaddr_in local_addr[MAX_INST]; -int addr_len[MAX_INST]; - - -uint16_t pck_seq_num = 1; -uint16_t pck_seq_num_cur=0; -uint16_t pck_seq_num_prev=0; - -int eth_socket_init_udp(openair0_device *device) { - - int i = 0; - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - char str_local[INET_ADDRSTRLEN]; - char str_remote[INET_ADDRSTRLEN]; - const char *local_ip, *remote_ip; - int local_port=0, remote_port=0; - int sock_dom=0; - int sock_type=0; - int sock_proto=0; - int enable=1; - - if (device->host_type == RRH_HOST ) { - local_ip = device->openair0_cfg->my_addr; - local_port = device->openair0_cfg->my_port; - remote_ip = "0.0.0.0"; - remote_port = 0; - printf("[%s] local ip addr %s port %d\n", "RRH", local_ip, local_port); - } else { - local_ip = device->openair0_cfg->my_addr; - local_port = device->openair0_cfg->my_port; - remote_ip = device->openair0_cfg->remote_addr; - remote_port = device->openair0_cfg->remote_port; - printf("[%s] local ip addr %s port %d\n","BBU", local_ip, local_port); - } - - /* Open socket to send on */ - sock_dom=AF_INET; - sock_type=SOCK_DGRAM; - sock_proto=IPPROTO_UDP; - - if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) { - perror("ETHERNET: Error opening socket"); - exit(0); - } - - /* initialize addresses */ - for (i=0; i< MAX_INST; i++) { - bzero((void *)&(dest_addr[i]), sizeof(dest_addr[i])); - bzero((void *)&(local_addr[i]), sizeof(local_addr[i])); - } - - addr_len[Mod_id] = sizeof(struct sockaddr_in); - - dest_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,remote_ip,&(dest_addr[Mod_id].sin_addr.s_addr)); - dest_addr[Mod_id].sin_port=htons(remote_port); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str_remote, INET_ADDRSTRLEN); - - - local_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,local_ip,&(local_addr[Mod_id].sin_addr.s_addr)); - local_addr[Mod_id].sin_port=htons(local_port); - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str_local, INET_ADDRSTRLEN); - - - /* set reuse address flag */ - if (setsockopt(eth->sockfd[Mod_id], SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { - perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); - exit(0); - } - - /* want to receive -> so bind */ - if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) { - perror("ETHERNET: Cannot bind to socket"); - exit(0); - } else { - printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(local_addr[Mod_id].sin_port)); - } - - return 0; -} - -int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - - // Read nblocks info from packet itself - int nblocks = nsamps; - int bytes_received=0; - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - - ssize_t packet_size = sizeof_IF4p5_header_t; - IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); - - - bytes_received = recvfrom(eth->sockfd[Mod_id], - buff[0], - packet_size, - 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); - - if (bytes_received ==-1) { - eth->num_rx_errors++; - perror("ETHERNET IF4p5 READ (header): "); - exit(-1); - } - - *timestamp = test_header->sub_type; - - if (test_header->sub_type == IF4p5_PDLFFT) { - packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); - } else if (test_header->sub_type == IF4p5_PULFFT) { - packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); - } else { - packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; - } - - - while(bytes_received < packet_size) { - bytes_received = recvfrom(eth->sockfd[Mod_id], - buff[0], - packet_size, - 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); - if (bytes_received ==-1) { - eth->num_rx_errors++; - perror("ETHERNET IF4p5 READ (payload): "); - exit(-1); - } else { - eth->rx_actual_nsamps = bytes_received>>1; - eth->rx_count++; - } - } - - eth->rx_nsamps = nsamps; - return(bytes_received); -} - -int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - - int nblocks = nsamps; - int bytes_sent = 0; - - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - - ssize_t packet_size; - - if (flags == IF4p5_PDLFFT) { - packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); - } else if (flags == IF4p5_PULFFT) { - packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); - } else if (flags == IF4p5_PRACH) { - packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; - } else { - printf("trx_eth_write_udp_IF4p5: unknown flags %d\n",flags); - return(-1); - } - - eth->tx_nsamps = nblocks; - - bytes_sent = sendto(eth->sockfd[Mod_id], - buff[0], - packet_size, - 0, - (struct sockaddr*)&dest_addr[Mod_id], - addr_len[Mod_id]); - - if (bytes_sent == -1) { - eth->num_tx_errors++; - perror("ETHERNET WRITE: "); - exit(-1); - } else { - eth->tx_actual_nsamps = bytes_sent>>1; - eth->tx_count++; - } - - return (bytes_sent); -} - -int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags) { - - int bytes_sent=0; - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - int sendto_flag =0; - int i=0; - //sendto_flag|=flags; - eth->tx_nsamps=nsamps; - - for (i=0;ipck_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 + 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); - - while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) { -#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, - bytes_sent); -#endif - /* Send packet */ - bytes_sent += sendto(eth->sockfd[Mod_id], - buff2, - UDP_PACKET_SIZE_BYTES(nsamps), - sendto_flag, - (struct sockaddr*)&dest_addr[Mod_id], - addr_len[Mod_id]); - - if ( bytes_sent == -1) { - eth->num_tx_errors++; - perror("ETHERNET WRITE: "); - exit(-1); - } else { -#if DEBUG - printf("------- TX ------: nu=%d an_id=%d ts%d bytes_send=%d\n", - *(int16_t *)buff2, - *(int16_t *)(buff2 + sizeof(int16_t)), - *(openair0_timestamp *)(buff2 + sizeof(int32_t)), - bytes_sent); - dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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,76800) ) pck_seq_num = 1; - } - } - /* tx buffer values restored */ - *(int32_t *)buff2 = temp0; - *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; - } - - return (bytes_sent-APP_HEADER_SIZE_BYTES)>>2; -} - - - -int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - - int bytes_received=0; - eth_state_t *eth = (eth_state_t*)device->priv; - // openair0_timestamp prev_timestamp = -1; - int Mod_id = device->Mod_id; - int rcvfrom_flag =0; - int block_cnt=0; - int again_cnt=0; - int i=0; - - eth->rx_nsamps=nsamps; - - for (i=0;isockfd[Mod_id], - buff2, - UDP_PACKET_SIZE_BYTES(nsamps), - rcvfrom_flag, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); - - if (bytes_received ==-1) { - eth->num_rx_errors++; - if (errno == EAGAIN) { - again_cnt++; - usleep(10); - if (again_cnt == 1000) { - perror("ETHERNET READ: "); - 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 READ: "); - exit(-1); - } else { - printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n"); - goto again; - } - } - } else { -#if DEBUG - printf("------- RX------: nu=%d an_id=%d ts%d bytes_recv=%d\n", - *(int16_t *)buff2, - *(int16_t *)(buff2 + sizeof(int16_t)), - *(openair0_timestamp *)(buff2 + sizeof(int32_t)), - bytes_received); - dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; - } else { - pck_seq_num_prev = 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==75) && (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); - } - 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); - eth->rx_actual_nsamps=bytes_received>>2; - eth->rx_count++; - } - - } - /* tx buffer values restored */ - *(int32_t *)buff2 = temp0; - *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; - - } - return (bytes_received-APP_HEADER_SIZE_BYTES)>>2; -} - - - - -int eth_set_dev_conf_udp(openair0_device *device) { - - int Mod_id = device->Mod_id; - eth_state_t *eth = (eth_state_t*)device->priv; - void *msg; - ssize_t msg_len; - - - /* a BBU client sents to RRH a set of configuration parameters (openair0_config_t) - so that RF front end is configured appropriately and - frame/packet size etc. can be set */ - - msg=malloc(sizeof(openair0_config_t)); - msg_len=sizeof(openair0_config_t); - memcpy(msg,(void*)device->openair0_cfg,msg_len); - - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - - return 0; -} - -int eth_get_dev_conf_udp(openair0_device *device) { - - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN]; - void *msg; - ssize_t msg_len; - - msg=malloc(sizeof(openair0_config_t)); - msg_len=sizeof(openair0_config_t); - - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); - - /* RRH receives from BBU openair0_config_t */ - if (recvfrom(eth->sockfd[Mod_id], - msg, - msg_len, - 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - device->openair0_cfg=(openair0_config_t *)msg; - - /* get remote ip address and port */ - /* inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->remote_port =ntohs(dest_addr[Mod_id].sin_port); */ - /* device->openair0_cfg->remote_addr =str1; */ - - /* /\* restore local ip address and port *\/ */ - /* inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->my_port =ntohs(local_addr[Mod_id].sin_port); */ - /* device->openair0_cfg->my_addr =str; */ - - /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd[Mod_id],str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ - return 0; -} +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + + *******************************************************************************/ +/*! \file ethernet_lib.c + * \brief API to stream I/Q samples over standard ethernet + * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp + * \date 2015 + * \version 0.2 + * \company Eurecom + * \maintainer: navid.nikaein@eurecom.fr + * \note + * \warning + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vcd_signal_dumper.h" + +#include "common_lib.h" +#include "ethernet_lib.h" + +#define DEBUG 0 +struct sockaddr_in dest_addr[MAX_INST]; +struct sockaddr_in local_addr[MAX_INST]; +int addr_len[MAX_INST]; + + +uint16_t pck_seq_num = 1; +uint16_t pck_seq_num_cur=0; +uint16_t pck_seq_num_prev=0; + +int eth_socket_init_udp(openair0_device *device) { + + int i = 0; + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + char str_local[INET_ADDRSTRLEN]; + char str_remote[INET_ADDRSTRLEN]; + const char *local_ip, *remote_ip; + int local_port=0, remote_port=0; + int sock_dom=0; + int sock_type=0; + int sock_proto=0; + int enable=1; + + if (device->host_type == RRH_HOST ) { + local_ip = device->openair0_cfg->my_addr; + local_port = device->openair0_cfg->my_port; + remote_ip = "0.0.0.0"; + remote_port = 0; + printf("[%s] local ip addr %s port %d\n", "RRH", local_ip, local_port); + } else { + local_ip = device->openair0_cfg->my_addr; + local_port = device->openair0_cfg->my_port; + remote_ip = device->openair0_cfg->remote_addr; + remote_port = device->openair0_cfg->remote_port; + printf("[%s] local ip addr %s port %d\n","BBU", local_ip, local_port); + } + + /* Open socket to send on */ + sock_dom=AF_INET; + sock_type=SOCK_DGRAM; + sock_proto=IPPROTO_UDP; + + if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) { + perror("ETHERNET: Error opening socket"); + exit(0); + } + + /* initialize addresses */ + for (i=0; i< MAX_INST; i++) { + bzero((void *)&(dest_addr[i]), sizeof(dest_addr[i])); + bzero((void *)&(local_addr[i]), sizeof(local_addr[i])); + } + + addr_len[Mod_id] = sizeof(struct sockaddr_in); + + dest_addr[Mod_id].sin_family = AF_INET; + inet_pton(AF_INET,remote_ip,&(dest_addr[Mod_id].sin_addr.s_addr)); + dest_addr[Mod_id].sin_port=htons(remote_port); + inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str_remote, INET_ADDRSTRLEN); + + + local_addr[Mod_id].sin_family = AF_INET; + inet_pton(AF_INET,local_ip,&(local_addr[Mod_id].sin_addr.s_addr)); + local_addr[Mod_id].sin_port=htons(local_port); + inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str_local, INET_ADDRSTRLEN); + + + /* set reuse address flag */ + if (setsockopt(eth->sockfd[Mod_id], SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { + perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); + exit(0); + } + + /* want to receive -> so bind */ + if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) { + perror("ETHERNET: Cannot bind to socket"); + exit(0); + } else { + printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(local_addr[Mod_id].sin_port)); + } + + return 0; +} + +int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { + + // Read nblocks info from packet itself + int nblocks = nsamps; + int bytes_received=-1; + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + + ssize_t packet_size = sizeof_IF4p5_header_t; + IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); + + int block_cnt=0; + int again_cnt=0; + packet_size = max(UDP_IF4p5_PRACH_SIZE_BYTES, max(UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks), UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks))); + + while(bytes_received == -1) { + again: + bytes_received = recvfrom(eth->sockfd[Mod_id], + buff[0], + packet_size, + 0, + (struct sockaddr *)&dest_addr[Mod_id], + (socklen_t *)&addr_len[Mod_id]); + if (bytes_received ==-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 { + *timestamp = test_header->sub_type; + eth->rx_actual_nsamps = bytes_received>>1; + eth->rx_count++; + } + } + //printf("size of third %d subtype %d frame %d subframe %d symbol %d \n", bytes_received, test_header->sub_type, ((test_header->frame_status)>>6)&0xffff, ((test_header->frame_status)>>22)&0x000f, ((test_header->frame_status)>>26)&0x000f) ; + + eth->rx_nsamps = nsamps; + return(bytes_received); +} + +int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { + + int nblocks = nsamps; + int bytes_sent = 0; + + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + + ssize_t packet_size; + + if (flags == IF4p5_PDLFFT) { + packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PULFFT) { + packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PRACH) { + packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; + } else { + printf("trx_eth_write_udp_IF4p5: unknown flags %d\n",flags); + return(-1); + } + + eth->tx_nsamps = nblocks; + + bytes_sent = sendto(eth->sockfd[Mod_id], + buff[0], + packet_size, + 0, + (struct sockaddr*)&dest_addr[Mod_id], + addr_len[Mod_id]); + + if (bytes_sent == -1) { + eth->num_tx_errors++; + perror("ETHERNET WRITE: "); + exit(-1); + } else { + eth->tx_actual_nsamps = bytes_sent>>1; + eth->tx_count++; + } + + return (bytes_sent); +} + +int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags) { + + int bytes_sent=0; + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + int sendto_flag =0; + int i=0; + //sendto_flag|=flags; + eth->tx_nsamps=nsamps; + + for (i=0;ipck_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 + 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); + + while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) { +#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, + bytes_sent); +#endif + /* Send packet */ + bytes_sent += sendto(eth->sockfd[Mod_id], + buff2, + UDP_PACKET_SIZE_BYTES(nsamps), + sendto_flag, + (struct sockaddr*)&dest_addr[Mod_id], + addr_len[Mod_id]); + + if ( bytes_sent == -1) { + eth->num_tx_errors++; + perror("ETHERNET WRITE: "); + exit(-1); + } else { +#if DEBUG + printf("------- TX ------: nu=%d an_id=%d ts%d bytes_send=%d\n", + *(int16_t *)buff2, + *(int16_t *)(buff2 + sizeof(int16_t)), + *(openair0_timestamp *)(buff2 + sizeof(int32_t)), + bytes_sent); + dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; + } + } + /* tx buffer values restored */ + *(int32_t *)buff2 = temp0; + *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; + } + + return (bytes_sent-APP_HEADER_SIZE_BYTES)>>2; +} + + + +int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { + + int bytes_received=0; + eth_state_t *eth = (eth_state_t*)device->priv; + // openair0_timestamp prev_timestamp = -1; + int Mod_id = device->Mod_id; + int rcvfrom_flag =0; + int block_cnt=0; + int again_cnt=0; + int i=0; + + eth->rx_nsamps=nsamps; + + for (i=0;isockfd[Mod_id], + buff2, + UDP_PACKET_SIZE_BYTES(nsamps), + rcvfrom_flag, + (struct sockaddr *)&dest_addr[Mod_id], + (socklen_t *)&addr_len[Mod_id]); + + if (bytes_received ==-1) { + eth->num_rx_errors++; + if (errno == EAGAIN) { + again_cnt++; + usleep(10); + if (again_cnt == 1000) { + perror("ETHERNET READ: "); + 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 READ: "); + exit(-1); + } else { + printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n"); + goto again; + } + } + } else { +#if DEBUG + printf("------- RX------: nu=%d an_id=%d ts%d bytes_recv=%d\n", + *(int16_t *)buff2, + *(int16_t *)(buff2 + sizeof(int16_t)), + *(openair0_timestamp *)(buff2 + sizeof(int32_t)), + bytes_received); + dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; + } else { + pck_seq_num_prev = 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); + } + 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); + eth->rx_actual_nsamps=bytes_received>>2; + eth->rx_count++; + } + + } + /* tx buffer values restored */ + *(int32_t *)buff2 = temp0; + *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; + + } + return (bytes_received-APP_HEADER_SIZE_BYTES)>>2; +} + + + + +int eth_set_dev_conf_udp(openair0_device *device) { + + int Mod_id = device->Mod_id; + eth_state_t *eth = (eth_state_t*)device->priv; + void *msg; + ssize_t msg_len; + + + /* a BBU client sents to RRH a set of configuration parameters (openair0_config_t) + so that RF front end is configured appropriately and + frame/packet size etc. can be set */ + + msg=malloc(sizeof(openair0_config_t)); + msg_len=sizeof(openair0_config_t); + memcpy(msg,(void*)device->openair0_cfg,msg_len); + + if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],addr_len[Mod_id])==-1) { + perror("ETHERNET: "); + exit(0); + } + + return 0; +} + +int eth_get_dev_conf_udp(openair0_device *device) { + + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN]; + void *msg; + ssize_t msg_len; + + msg=malloc(sizeof(openair0_config_t)); + msg_len=sizeof(openair0_config_t); + + inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); + + /* RRH receives from BBU openair0_config_t */ + if (recvfrom(eth->sockfd[Mod_id], + msg, + msg_len, + 0, + (struct sockaddr *)&dest_addr[Mod_id], + (socklen_t *)&addr_len[Mod_id])==-1) { + perror("ETHERNET: "); + exit(0); + } + device->openair0_cfg=(openair0_config_t *)msg; + + /* get remote ip address and port */ + /* inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->remote_port =ntohs(dest_addr[Mod_id].sin_port); */ + /* device->openair0_cfg->remote_addr =str1; */ + + /* /\* restore local ip address and port *\/ */ + /* inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->my_port =ntohs(local_addr[Mod_id].sin_port); */ + /* device->openair0_cfg->my_addr =str; */ + + /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd[Mod_id],str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ + return 0; +} From 08499a69e2ed74157188b35ac4a74740a9444e6d Mon Sep 17 00:00:00 2001 From: luhan wang Date: Thu, 20 Oct 2016 14:19:18 +0200 Subject: [PATCH 04/59] modifications for IF4p5 UDP transport --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 104 +++++++++++++++++-------- 1 file changed, 72 insertions(+), 32 deletions(-) mode change 100644 => 100755 openair1/PHY/LTE_TRANSPORT/if4_tools.c diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c old mode 100644 new mode 100755 index 26e19df2a4..1176450ddb --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -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); - data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t); - - gen_IF4p5_dl_header(dl_header, frame, subframe); + 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_dl_header(packet_header, frame, subframe); for (symbol_id=0; symbol_idsymbols_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); - data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t); - - gen_IF4p5_ul_header(ul_header, frame, subframe); + 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_ul_header(packet_header, frame, subframe); for (symbol_id=0; symbol_idsymbols_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,16 +146,25 @@ 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; + 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); - IF4p5_header_t *prach_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES); - data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t); + 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)); + } - gen_IF4p5_prach_header(prach_header, frame, subframe); - - memcpy((int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t), - (&rxsigF[0][k]), - db_fulllength*sizeof(int16_t)); - if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice, symbol_id, &tx_buffer, @@ -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 ); @@ -191,12 +213,18 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t 0) < 0) { perror("ETHERNET read"); } - - 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); + + 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; + *subframe = ((packet_header->frame_status)>>22)&0x000f; + *packet_type = packet_header->sub_type; if (*packet_type == IF4p5_PDLFFT) { @@ -234,11 +262,17 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t } else if (*packet_type == IF4p5_PRACH) { // FIX: hard coded prach samples length db_fulllength = 840*2; - - memcpy((&rxsigF[0][0]), - (int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t), - db_fulllength*sizeof(int16_t)); - + + 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 - eNB->ifbuffer.tx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); - eNB->ifbuffer.rx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + 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); + } } From 5affbe3848196e8819ede04b23857c0915b992b5 Mon Sep 17 00:00:00 2001 From: luhan wang Date: Thu, 20 Oct 2016 17:32:56 +0200 Subject: [PATCH 05/59] added resynchronization parameters to PHY_VARS_eNB --- openair1/PHY/defs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 3532fa3c6f..40444d284f 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -410,6 +410,8 @@ typedef struct PHY_VARS_eNB_s { int single_thread_flag; openair0_rf_map rf_map; int abstraction_flag; + int iframe_offset; + int isubframe_offset; void (*do_prach)(struct PHY_VARS_eNB_s *eNB); void (*fep)(struct PHY_VARS_eNB_s *eNB); int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); From db8c2a05370628af0435f08ebfa51b22346b83c6 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 23 Oct 2016 23:29:21 -0700 Subject: [PATCH 06/59] update of ETHERNET interfaces (removal of global variables). --- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c | 79 +++++++------ targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 104 ++++++++---------- .../ETHERNET/USERSPACE/LIB/ethernet_lib.c | 68 ++++++------ .../ETHERNET/USERSPACE/LIB/ethernet_lib.h | 16 ++- 4 files changed, 134 insertions(+), 133 deletions(-) diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c index 126030d3d4..1bd3c068ef 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c @@ -54,16 +54,14 @@ #define DEBUG 0 -struct sockaddr_ll dest_addr[MAX_INST]; -struct sockaddr_ll local_addr[MAX_INST]; -int addr_len[MAX_INST]; -struct ifreq if_index[MAX_INST]; +//struct sockaddr_ll dest_addr[MAX_INST]; +//struct sockaddr_ll local_addr[MAX_INST]; +//int addr_len[MAX_INST]; +//struct ifreq if_index[MAX_INST]; int eth_socket_init_raw(openair0_device *device) { - int i = 0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; const char *local_mac, *remote_mac; int sock_dom=0; int sock_type=0; @@ -85,30 +83,29 @@ int eth_socket_init_raw(openair0_device *device) { sock_dom=AF_PACKET; sock_type=SOCK_RAW; sock_proto=IPPROTO_RAW; - if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) { + if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) { perror("ETHERNET: Error opening RAW socket"); exit(0); } /* initialize destination address */ - for (i=0; i< MAX_INST; i++) { - bzero((void *)&(local_addr[i]), sizeof(struct sockaddr_ll)); - bzero((void *)&(if_index[i]), sizeof(struct ifreq)); - } + bzero((void *)&(eth->local_addr_ll), sizeof(struct sockaddr_ll)); + bzero((void *)&(eth->if_index), sizeof(struct ifreq)); + /* Get the index of the interface to send on */ - strcpy(if_index[Mod_id].ifr_name,eth->if_name[Mod_id]); - if (ioctl(eth->sockfd[Mod_id], SIOCGIFINDEX, &(if_index[Mod_id])) < 0) + strcpy(eth->if_index.ifr_name,eth->if_name); + if (ioctl(eth->sockfd, SIOCGIFINDEX, &(eth->if_index)) < 0) perror("SIOCGIFINDEX"); - local_addr[Mod_id].sll_family = AF_PACKET; - local_addr[Mod_id].sll_ifindex = if_index[Mod_id].ifr_ifindex; + eth->local_addr_ll.sll_family = AF_PACKET; + eth->local_addr_ll.sll_ifindex = eth->if_index.ifr_ifindex; /* hear traffic from specific protocol*/ - local_addr[Mod_id].sll_protocol = htons((short)device->openair0_cfg->my_port); - local_addr[Mod_id].sll_halen = ETH_ALEN; - local_addr[Mod_id].sll_pkttype = PACKET_OTHERHOST; - addr_len[Mod_id] = sizeof(struct sockaddr_ll); + eth->local_addr_ll.sll_protocol = htons((short)device->openair0_cfg->my_port); + eth->local_addr_ll.sll_halen = ETH_ALEN; + eth->local_addr_ll.sll_pkttype = PACKET_OTHERHOST; + eth->addr_len = sizeof(struct sockaddr_ll); - if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) { + if (bind(eth->sockfd,(struct sockaddr *)ð->local_addr_ll,eth->addr_len)<0) { perror("ETHERNET: Cannot bind to socket"); exit(0); } @@ -121,7 +118,7 @@ int eth_socket_init_raw(openair0_device *device) { } else { eth->eh.ether_type = htons((short)device->openair0_cfg->my_port); } - printf("[%s] binding mod_%d to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),Mod_id,eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]); + printf("[%s] binding to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]); return 0; } @@ -131,7 +128,6 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi int bytes_sent=0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; int sendto_flag =0; int i=0; //sendto_flag|=flags; @@ -164,7 +160,7 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi bytes_sent); #endif /* Send packet */ - bytes_sent += send(eth->sockfd[Mod_id], + bytes_sent += send(eth->sockfd, buff2, RAW_PACKET_SIZE_BYTES(nsamps), sendto_flag); @@ -202,7 +198,6 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam int bytes_sent = 0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; ssize_t packet_size; @@ -221,7 +216,7 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam memcpy(buff[0], (void*)ð->eh, MAC_HEADER_SIZE_BYTES); - bytes_sent = send(eth->sockfd[Mod_id], + bytes_sent = send(eth->sockfd, buff[0], packet_size, 0); @@ -245,7 +240,6 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi int bytes_received=0; int i=0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; int rcvfrom_flag =0; eth->rx_nsamps=nsamps; @@ -263,7 +257,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi bytes_received=0; while(bytes_received < RAW_PACKET_SIZE_BYTES(nsamps)) { - bytes_received +=recv(eth->sockfd[Mod_id], + bytes_received +=recv(eth->sockfd, buff2, RAW_PACKET_SIZE_BYTES(nsamps), rcvfrom_flag); @@ -306,13 +300,15 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam int nblocks = nsamps; int bytes_received=0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; 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); +#ifdef DEBUG + printf("Reading from device %p, eth %p, sockfd %d\n",device,eth,eth->sockfd); +#endif - bytes_received = recv(eth->sockfd[Mod_id], + bytes_received = recv(eth->sockfd, buff[0], packet_size, MSG_PEEK); @@ -321,7 +317,12 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam perror("ETHERNET IF4p5 READ (header): "); exit(-1); } - +#ifdef DEBUG + for (int i=0;isub_type; if (test_header->sub_type == IF4p5_PDLFFT) { @@ -334,7 +335,7 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam while(bytes_received < packet_size) { - bytes_received = recv(eth->sockfd[Mod_id], + bytes_received = recv(eth->sockfd, buff[0], packet_size, 0); @@ -356,7 +357,6 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam int eth_set_dev_conf_raw(openair0_device *device) { - int Mod_id = device->Mod_id; eth_state_t *eth = (eth_state_t*)device->priv; void *msg; ssize_t msg_len; @@ -372,7 +372,7 @@ int eth_set_dev_conf_raw(openair0_device *device) { memcpy(msg,(void*)ð->eh,MAC_HEADER_SIZE_BYTES); memcpy((msg+MAC_HEADER_SIZE_BYTES),(void*)device->openair0_cfg,sizeof(openair0_config_t)); - if (send(eth->sockfd[Mod_id], + if (send(eth->sockfd, msg, msg_len, 0)==-1) { @@ -388,7 +388,6 @@ int eth_set_dev_conf_raw(openair0_device *device) { int eth_set_dev_conf_raw_IF4p5(openair0_device *device) { // use for cc_id info - int Mod_id = device->Mod_id; eth_state_t *eth = (eth_state_t*)device->priv; void *msg; ssize_t msg_len; @@ -404,7 +403,7 @@ int eth_set_dev_conf_raw_IF4p5(openair0_device *device) { memcpy(msg,(void*)ð->eh,MAC_HEADER_SIZE_BYTES); memcpy((msg+MAC_HEADER_SIZE_BYTES),(void*)device->openair0_cfg,sizeof(openair0_config_t)); - if (send(eth->sockfd[Mod_id], + if (send(eth->sockfd, msg, msg_len, 0)==-1) { @@ -419,7 +418,6 @@ int eth_set_dev_conf_raw_IF4p5(openair0_device *device) { int eth_get_dev_conf_raw(openair0_device *device) { eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; void *msg; ssize_t msg_len; @@ -427,7 +425,7 @@ int eth_get_dev_conf_raw(openair0_device *device) { msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t); /* RRH receives from BBU openair0_config_t */ - if (recv(eth->sockfd[Mod_id], + if (recv(eth->sockfd, msg, msg_len, 0)==-1) { @@ -439,7 +437,7 @@ int eth_get_dev_conf_raw(openair0_device *device) { memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN); //memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t)); device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES); - printf("[%s] binding mod_%d to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),Mod_id,eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]); + printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]); return 0; } @@ -449,7 +447,6 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) { // use for cc_id info eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; void *msg; ssize_t msg_len; @@ -457,7 +454,7 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) { msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t); /* RRH receives from BBU openair0_config_t */ - if (recv(eth->sockfd[Mod_id], + if (recv(eth->sockfd, msg, msg_len, 0)==-1) { @@ -469,7 +466,7 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) { memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN); //memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t)); //device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES); - printf("[%s] binding mod_%d to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),Mod_id,eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]); + printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]); return 0; } diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index 7d5fecbbf2..fc8c175ae9 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -54,9 +54,9 @@ #include "ethernet_lib.h" #define DEBUG 0 -struct sockaddr_in dest_addr[MAX_INST]; -struct sockaddr_in local_addr[MAX_INST]; -int addr_len[MAX_INST]; +//struct sockaddr_in dest_addr[MAX_INST]; +//struct sockaddr_in local_addr[MAX_INST]; +//int addr_len[MAX_INST]; uint16_t pck_seq_num = 1; @@ -65,9 +65,7 @@ uint16_t pck_seq_num_prev=0; int eth_socket_init_udp(openair0_device *device) { - int i = 0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; char str_local[INET_ADDRSTRLEN]; char str_remote[INET_ADDRSTRLEN]; const char *local_ip, *remote_ip; @@ -96,43 +94,42 @@ int eth_socket_init_udp(openair0_device *device) { sock_type=SOCK_DGRAM; sock_proto=IPPROTO_UDP; - if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) { + if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) { perror("ETHERNET: Error opening socket"); exit(0); } /* initialize addresses */ - for (i=0; i< MAX_INST; i++) { - bzero((void *)&(dest_addr[i]), sizeof(dest_addr[i])); - bzero((void *)&(local_addr[i]), sizeof(local_addr[i])); - } + bzero((void *)&(eth->dest_addr), sizeof(eth->dest_addr)); + bzero((void *)&(eth->local_addr), sizeof(eth->local_addr)); + - addr_len[Mod_id] = sizeof(struct sockaddr_in); + eth->addr_len = sizeof(struct sockaddr_in); - dest_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,remote_ip,&(dest_addr[Mod_id].sin_addr.s_addr)); - dest_addr[Mod_id].sin_port=htons(remote_port); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str_remote, INET_ADDRSTRLEN); + eth->dest_addr.sin_family = AF_INET; + inet_pton(AF_INET,remote_ip,&(eth->dest_addr.sin_addr.s_addr)); + eth->dest_addr.sin_port=htons(remote_port); + inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN); - local_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,local_ip,&(local_addr[Mod_id].sin_addr.s_addr)); - local_addr[Mod_id].sin_port=htons(local_port); - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str_local, INET_ADDRSTRLEN); + eth->local_addr.sin_family = AF_INET; + inet_pton(AF_INET,local_ip,&(eth->local_addr.sin_addr.s_addr)); + eth->local_addr.sin_port=htons(local_port); + inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str_local, INET_ADDRSTRLEN); /* set reuse address flag */ - if (setsockopt(eth->sockfd[Mod_id], SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); exit(0); } /* want to receive -> so bind */ - if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) { + if (bind(eth->sockfd,(struct sockaddr *)ð->local_addr,eth->addr_len)<0) { perror("ETHERNET: Cannot bind to socket"); exit(0); } else { - printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(local_addr[Mod_id].sin_port)); + printf("[%s] binding to %s:%d\n","RRH",str_local,ntohs(eth->local_addr.sin_port)); } return 0; @@ -144,8 +141,7 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam int nblocks = nsamps; int bytes_received=-1; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - + ssize_t packet_size = sizeof_IF4p5_header_t; IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); @@ -155,12 +151,12 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam while(bytes_received == -1) { again: - bytes_received = recvfrom(eth->sockfd[Mod_id], + bytes_received = recvfrom(eth->sockfd, buff[0], packet_size, 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len); if (bytes_received ==-1) { eth->num_rx_errors++; if (errno == EAGAIN) { @@ -206,7 +202,6 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam int bytes_sent = 0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; ssize_t packet_size; @@ -223,12 +218,12 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam eth->tx_nsamps = nblocks; - bytes_sent = sendto(eth->sockfd[Mod_id], + bytes_sent = sendto(eth->sockfd, buff[0], packet_size, 0, - (struct sockaddr*)&dest_addr[Mod_id], - addr_len[Mod_id]); + (struct sockaddr*)ð->dest_addr, + eth->addr_len); if (bytes_sent == -1) { eth->num_tx_errors++; @@ -246,7 +241,6 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi int bytes_sent=0; eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; int sendto_flag =0; int i=0; //sendto_flag|=flags; @@ -280,12 +274,12 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi bytes_sent); #endif /* Send packet */ - bytes_sent += sendto(eth->sockfd[Mod_id], + bytes_sent += sendto(eth->sockfd, buff2, UDP_PACKET_SIZE_BYTES(nsamps), sendto_flag, - (struct sockaddr*)&dest_addr[Mod_id], - addr_len[Mod_id]); + (struct sockaddr*)ð->dest_addr, + eth->addr_len); if ( bytes_sent == -1) { eth->num_tx_errors++; @@ -321,7 +315,6 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi int bytes_received=0; eth_state_t *eth = (eth_state_t*)device->priv; // openair0_timestamp prev_timestamp = -1; - int Mod_id = device->Mod_id; int rcvfrom_flag =0; int block_cnt=0; int again_cnt=0; @@ -350,12 +343,12 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi UDP_PACKET_SIZE_BYTES(nsamps) - bytes_received, bytes_received); #endif - bytes_received +=recvfrom(eth->sockfd[Mod_id], + bytes_received +=recvfrom(eth->sockfd, buff2, UDP_PACKET_SIZE_BYTES(nsamps), rcvfrom_flag, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len); if (bytes_received ==-1) { eth->num_rx_errors++; @@ -401,7 +394,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi /* 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))) { + 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); } VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM,pck_seq_num_cur); @@ -424,7 +417,6 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi int eth_set_dev_conf_udp(openair0_device *device) { - int Mod_id = device->Mod_id; eth_state_t *eth = (eth_state_t*)device->priv; void *msg; ssize_t msg_len; @@ -437,9 +429,10 @@ int eth_set_dev_conf_udp(openair0_device *device) { msg=malloc(sizeof(openair0_config_t)); msg_len=sizeof(openair0_config_t); memcpy(msg,(void*)device->openair0_cfg,msg_len); - - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],addr_len[Mod_id])==-1) { - perror("ETHERNET: "); + + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->dest_addr,eth->addr_len)==-1) { + perror("ETHERNET: sendto conf_udp"); + printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len); exit(0); } @@ -449,7 +442,6 @@ int eth_set_dev_conf_udp(openair0_device *device) { int eth_get_dev_conf_udp(openair0_device *device) { eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN]; void *msg; ssize_t msg_len; @@ -457,31 +449,31 @@ int eth_get_dev_conf_udp(openair0_device *device) { msg=malloc(sizeof(openair0_config_t)); msg_len=sizeof(openair0_config_t); - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); /* RRH receives from BBU openair0_config_t */ - if (recvfrom(eth->sockfd[Mod_id], + if (recvfrom(eth->sockfd, msg, msg_len, 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id])==-1) { - perror("ETHERNET: "); + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len)==-1) { + perror("ETHERNET: recv_from conf_udp"); exit(0); } device->openair0_cfg=(openair0_config_t *)msg; /* get remote ip address and port */ - /* inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->remote_port =ntohs(dest_addr[Mod_id].sin_port); */ + /* inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->remote_port =ntohs(eth->dest_addr.sin_port); */ /* device->openair0_cfg->remote_addr =str1; */ /* /\* restore local ip address and port *\/ */ - /* inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->my_port =ntohs(local_addr[Mod_id].sin_port); */ + /* inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->my_port =ntohs(eth->local_addr.sin_port); */ /* device->openair0_cfg->my_addr =str; */ - /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd[Mod_id],str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ + /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ return 0; } diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 6079781ba1..45778849b2 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -52,9 +52,9 @@ #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 num_devices_eth = 0; +//struct sockaddr_in dest_addr[MAX_INST]; +//int dest_addr_len[MAX_INST]; int trx_eth_start(openair0_device *device) { @@ -119,13 +119,12 @@ int trx_eth_start(openair0_device *device) { void trx_eth_end(openair0_device *device) { eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; /* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */ - if ( close(eth->sockfd[Mod_id]) <0 ) { + if ( close(eth->sockfd) <0 ) { perror("ETHERNET: Failed to close socket"); exit(0); } else { - printf("[%s] socket for mod_id %d has been successfully closed.\n",(device->host_type == BBU_HOST)? "BBU":"RRH",Mod_id); + printf("[%s] socket has been successfully closed.\n",(device->host_type == BBU_HOST)? "BBU":"RRH"); } } @@ -133,15 +132,15 @@ void trx_eth_end(openair0_device *device) { int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) { - int Mod_id = device->Mod_id; eth_state_t *eth = (eth_state_t*)device->priv; /* BBU sends a message to RRH */ - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],dest_addr_len[Mod_id])==-1) { + + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->dest_addr,eth->addr_len)==-1) { perror("ETHERNET: "); exit(0); } - + return 0; } @@ -149,19 +148,21 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) { int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) { eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; /* RRH receives from BBU a message */ - if (recvfrom(eth->sockfd[Mod_id], + + if (recvfrom(eth->sockfd, msg, msg_len, 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&dest_addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len)==-1) { + perror("ETHERNET: recv_from in trx_eth_reply "); + exit(0); + } + + + return 0; } @@ -191,7 +192,6 @@ int trx_eth_reset_stats(openair0_device* device) { int ethernet_tune(openair0_device *device, unsigned int option, int value) { eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id=device->Mod_id; struct timeval timeout; struct ifreq ifr; char system_cmd[256]; @@ -204,7 +204,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { /****************** socket level options ************************/ switch(option) { case SND_BUF_SIZE: /* transmit socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_SNDBUF, &value,sizeof(value))) { @@ -215,7 +215,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { break; case RCV_BUF_SIZE: /* receive socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_RCVBUF, &value,sizeof(value))) { @@ -228,7 +228,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { case RCV_TIMEOUT: timeout.tv_sec = value/1000000; timeout.tv_usec = value%1000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof(timeout))) { @@ -241,7 +241,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { case SND_TIMEOUT: timeout.tv_sec = value/1000000000; timeout.tv_usec = value%1000000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,sizeof(timeout))) { @@ -255,27 +255,27 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { /******************* interface level options *************************/ case MTU_SIZE: /* change MTU of the eth interface */ ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name,eth->if_name, sizeof(ifr.ifr_name)); ifr.ifr_mtu =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFMTU,(caddr_t)&ifr) < 0 ) + if (ioctl(eth->sockfd,SIOCSIFMTU,(caddr_t)&ifr) < 0 ) perror ("[ETHERNET] Can't set the MTU"); else - printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_mtu); + printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name,ifr.ifr_mtu); break; case TX_Q_LEN: /* change TX queue length of eth interface */ ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name,eth->if_name, sizeof(ifr.ifr_name)); ifr.ifr_qlen =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) + if (ioctl(eth->sockfd,SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) perror ("[ETHERNET] Can't set the txqueuelen"); else - printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_qlen); + printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name,ifr.ifr_qlen); break; /******************* device level options *************************/ case COALESCE_PAR: - ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -C %s rx-usecs %d",eth->if_name[Mod_id],value); + ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -C %s rx-usecs %d",eth->if_name,value); if (ret > 0) { ret=system(system_cmd); if (ret == -1) { @@ -290,8 +290,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { break; case PAUSE_PAR: - if (value==1) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg off rx off tx off",eth->if_name[Mod_id]); - else if (value==0) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg on rx on tx on",eth->if_name[Mod_id]); + if (value==1) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg off rx off tx off",eth->if_name); + else if (value==0) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg on rx on tx on",eth->if_name); else break; if (ret > 0) { ret=system(system_cmd); @@ -307,7 +307,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { break; case RING_PAR: - ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -G %s val %d",eth->if_name[Mod_id],value); + ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -G %s val %d",eth->if_name,value); if (ret > 0) { ret=system(system_cmd); if (ret == -1) { @@ -351,7 +351,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth } printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH")); - device->Mod_id = num_devices_eth++; + device->Mod_id = 0;//num_devices_eth++; device->transp_type = ETHERNET_TP; device->trx_start_func = trx_eth_start; device->trx_request_func = trx_eth_request; @@ -383,7 +383,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth //device->trx_read_func = trx_eth_read_udp_IF4p5; } - eth->if_name[device->Mod_id] = eth_params->local_if_name; + eth->if_name = eth_params->local_if_name; device->priv = eth; /* device specific */ diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h index 0d80dbd023..9c65561566 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h @@ -62,11 +62,23 @@ typedef struct { /*!\brief socket file desc */ - int sockfd[MAX_INST]; + int sockfd; /*!\brief interface name */ - char *if_name[MAX_INST]; + char *if_name; /*!\brief buffer size */ unsigned int buffer_size; + /*!\brief destination address for UDP socket*/ + struct sockaddr_in dest_addr; + /*!\brief local address for UDP socket*/ + struct sockaddr_in local_addr; + /*!\brief address length for both UDP and RAW socket*/ + int addr_len; + /*!\brief destination address for RAW socket*/ + struct sockaddr_ll dest_addr_ll; + /*!\brief local address for RAW socket*/ + struct sockaddr_ll local_addr_ll; + /*!\brief inteface index for RAW socket*/ + struct ifreq if_index; /*!\brief timeout ms */ unsigned int rx_timeout_ms; /*!\brief timeout ms */ From 3c7ec4e41623cf94b2da41008a2da3487a9b90f7 Mon Sep 17 00:00:00 2001 From: luhan wang Date: Thu, 27 Oct 2016 07:47:47 +0200 Subject: [PATCH 07/59] added gtkw files for rcc --- targets/RT/USER/rcc_if4.gtkw | 161 +++++++++++++++++++++++++++++++++++ targets/RT/USER/rcc_if5.gtkw | 154 +++++++++++++++++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 targets/RT/USER/rcc_if4.gtkw create mode 100644 targets/RT/USER/rcc_if5.gtkw diff --git a/targets/RT/USER/rcc_if4.gtkw b/targets/RT/USER/rcc_if4.gtkw new file mode 100644 index 0000000000..e099e466c1 --- /dev/null +++ b/targets/RT/USER/rcc_if4.gtkw @@ -0,0 +1,161 @@ +[*] +[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI +[*] Sat Aug 6 15:00:27 2016 +[*] +[dumpfile] "/tmp/openair_dump_eNB.vcd" +[dumpfile_mtime] "Sat Aug 6 14:59:21 2016" +[dumpfile_size] 991809002 +[savefile] "/home/fourmi/openairinterface5g/targets/RT/USER/rcc_if4.gtkw" +[timestart] 0 +[size] 1301 716 +[pos] 309 0 +*-19.793451 7382528436 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[sst_width] 284 +[signals_width] 262 +[sst_expanded] 1 +[sst_vpaned_height] 294 +@24 +variables.trx_ts[63:0] +variables.trx_tst[63:0] +@28 +functions.recv_if4 +functions.send_if4 +functions.eNB_thread_rxtx0 +@24 +variables.frame_number_RX0_eNB[63:0] +variables.subframe_number_RX0_eNB[63:0] +variables.frame_number_TX0_eNB[63:0] +variables.subframe_number_TX0_eNB[63:0] +@28 +functions.phy_procedures_eNb_tx0 +functions.phy_procedures_eNb_rx_common0 +functions.phy_procedures_eNb_rx_uespec0 +functions.eNB_thread_rxtx1 +@24 +variables.frame_number_RX1_eNB[63:0] +variables.subframe_number_RX1_eNB[63:0] +variables.frame_number_TX1_eNB[63:0] +variables.subframe_number_TX1_eNB[63:0] +@29 +functions.phy_procedures_eNb_tx1 +@28 +functions.phy_procedures_eNb_rx_common1 +functions.phy_procedures_eNb_rx_uespec1 +functions.phy_enb_sfgen +functions.phy_eNB_slot_fep +functions.phy_enb_prach_rx +@24 +variables.dci_info[63:0] +variables.ue0_BO[63:0] +@420 +variables.ue0_BSR[63:0] +variables.ue0_timing_advance[63:0] +@28 +functions.macxface_initiate_ra_proc +functions.macxface_terminate_ra_proc +functions.phy_enb_ulsch_msg3 +functions.macxface_SR_indication +@420 +variables.ue0_SR_ENERGY[63:0] +variables.ue0_SR_THRES[63:0] +@28 +functions.phy_enb_ulsch_decoding0 +@24 +variables.ue0_res0[63:0] +@420 +variables.ue0_rssi0[63:0] +variables.ue0_MCS0[63:0] +variables.ue0_RB0[63:0] +@24 +variables.ue0_ROUND0[63:0] +variables.ue0_SFN0[63:0] +@28 +functions.phy_enb_ulsch_decoding1 +@24 +variables.ue0_res1[63:0] +@420 +variables.ue0_rssi1[63:0] +variables.ue0_MCS1[63:0] +variables.ue0_RB1[63:0] +@24 +variables.ue0_ROUND1[63:0] +variables.ue0_SFN1[63:0] +@28 +functions.phy_enb_ulsch_decoding2 +@24 +variables.ue0_res2[63:0] +@420 +variables.ue0_rssi2[63:0] +variables.ue0_MCS2[63:0] +variables.ue0_RB2[63:0] +@24 +variables.ue0_ROUND2[63:0] +variables.ue0_SFN2[63:0] +@28 +functions.phy_enb_ulsch_decoding3 +@24 +variables.ue0_res3[63:0] +@420 +variables.ue0_rssi3[63:0] +variables.ue0_MCS3[63:0] +variables.ue0_RB3[63:0] +@24 +variables.ue0_ROUND3[63:0] +variables.ue0_SFN3[63:0] +@28 +functions.phy_enb_ulsch_decoding4 +@420 +variables.ue0_rssi4[63:0] +@24 +variables.ue0_res4[63:0] +@420 +variables.ue0_MCS4[63:0] +variables.ue0_RB4[63:0] +@24 +variables.ue0_ROUND4[63:0] +variables.ue0_SFN4[63:0] +@28 +functions.phy_enb_ulsch_decoding5 +@24 +variables.ue0_res5[63:0] +@420 +variables.ue0_rssi5[63:0] +variables.ue0_MCS5[63:0] +variables.ue0_RB5[63:0] +@24 +variables.ue0_ROUND5[63:0] +variables.ue0_SFN5[63:0] +@28 +functions.phy_enb_ulsch_decoding6 +@24 +variables.ue0_res6[63:0] +@420 +variables.ue0_rssi6[63:0] +variables.ue0_MCS6[63:0] +variables.ue0_RB6[63:0] +@24 +variables.ue0_ROUND6[63:0] +variables.ue0_SFN6[63:0] +@28 +functions.phy_enb_ulsch_decoding7 +@24 +variables.ue0_res7[63:0] +@420 +variables.ue0_rssi7[63:0] +variables.ue0_MCS7[63:0] +variables.ue0_RB7[63:0] +@24 +variables.ue0_ROUND7[63:0] +variables.ue0_SFN7[63:0] +@28 +functions.phy_enb_prach_rx +functions.phy_eNB_dlsch_encoding +functions.phy_eNB_dlsch_modulation +functions.phy_eNB_dlsch_scrambling +functions.phy_enb_pdcch_tx +functions.phy_enb_rs_tx +functions.rrc_mac_config_req +functions.rlc_data_req +functions.udp_enb_task +[pattern_trace] 1 +[pattern_trace] 0 diff --git a/targets/RT/USER/rcc_if5.gtkw b/targets/RT/USER/rcc_if5.gtkw new file mode 100644 index 0000000000..d64a9ca0fb --- /dev/null +++ b/targets/RT/USER/rcc_if5.gtkw @@ -0,0 +1,154 @@ +[*] +[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI +[*] Sun Jul 31 13:30:42 2016 +[*] +[dumpfile] "/tmp/openair_dump_eNB.vcd" +[dumpfile_mtime] "Sun Jul 31 13:21:59 2016" +[dumpfile_size] 18273240 +[savefile] "/home/fourmi/openairinterface5g/targets/RT/USER/rcc_if5.gtkw" +[timestart] 24070893000 +[size] 1301 716 +[pos] 309 0 +*-19.793451 29026062100 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[sst_width] 284 +[signals_width] 262 +[sst_expanded] 1 +[sst_vpaned_height] 294 +@24 +variables.trx_ts[63:0] +variables.trx_tst[63:0] +@28 +functions.send_if5 +functions.recv_if5 +functions.eNB_thread_rxtx0 +@24 +variables.frame_number_RX0_eNB[63:0] +variables.subframe_number_RX0_eNB[63:0] +variables.frame_number_TX0_eNB[63:0] +variables.subframe_number_TX0_eNB[63:0] +@28 +functions.eNB_thread_rxtx1 +@24 +variables.frame_number_RX1_eNB[63:0] +variables.subframe_number_RX1_eNB[63:0] +variables.frame_number_TX1_eNB[63:0] +variables.subframe_number_TX1_eNB[63:0] +@28 +functions.phy_enb_sfgen +functions.phy_eNB_slot_fep +functions.phy_enb_prach_rx +@24 +variables.dci_info[63:0] +variables.ue0_BO[63:0] +@420 +variables.ue0_BSR[63:0] +variables.ue0_timing_advance[63:0] +@28 +functions.macxface_initiate_ra_proc +functions.macxface_terminate_ra_proc +functions.phy_enb_ulsch_msg3 +functions.macxface_SR_indication +@420 +variables.ue0_SR_ENERGY[63:0] +variables.ue0_SR_THRES[63:0] +@28 +functions.phy_enb_ulsch_decoding0 +@24 +variables.ue0_res0[63:0] +@420 +variables.ue0_rssi0[63:0] +variables.ue0_MCS0[63:0] +variables.ue0_RB0[63:0] +@24 +variables.ue0_ROUND0[63:0] +variables.ue0_SFN0[63:0] +@28 +functions.phy_enb_ulsch_decoding1 +@24 +variables.ue0_res1[63:0] +@420 +variables.ue0_rssi1[63:0] +variables.ue0_MCS1[63:0] +variables.ue0_RB1[63:0] +@24 +variables.ue0_ROUND1[63:0] +variables.ue0_SFN1[63:0] +@28 +functions.phy_enb_ulsch_decoding2 +@24 +variables.ue0_res2[63:0] +@420 +variables.ue0_rssi2[63:0] +variables.ue0_MCS2[63:0] +variables.ue0_RB2[63:0] +@24 +variables.ue0_ROUND2[63:0] +variables.ue0_SFN2[63:0] +@28 +functions.phy_enb_ulsch_decoding3 +@24 +variables.ue0_res3[63:0] +@420 +variables.ue0_rssi3[63:0] +variables.ue0_MCS3[63:0] +variables.ue0_RB3[63:0] +@24 +variables.ue0_ROUND3[63:0] +variables.ue0_SFN3[63:0] +@28 +functions.phy_enb_ulsch_decoding4 +@420 +variables.ue0_rssi4[63:0] +@24 +variables.ue0_res4[63:0] +@420 +variables.ue0_MCS4[63:0] +variables.ue0_RB4[63:0] +@24 +variables.ue0_ROUND4[63:0] +variables.ue0_SFN4[63:0] +@28 +functions.phy_enb_ulsch_decoding5 +@24 +variables.ue0_res5[63:0] +@420 +variables.ue0_rssi5[63:0] +variables.ue0_MCS5[63:0] +variables.ue0_RB5[63:0] +@24 +variables.ue0_ROUND5[63:0] +variables.ue0_SFN5[63:0] +@28 +functions.phy_enb_ulsch_decoding6 +@24 +variables.ue0_res6[63:0] +@420 +variables.ue0_rssi6[63:0] +variables.ue0_MCS6[63:0] +variables.ue0_RB6[63:0] +@24 +variables.ue0_ROUND6[63:0] +variables.ue0_SFN6[63:0] +@28 +functions.phy_enb_ulsch_decoding7 +@24 +variables.ue0_res7[63:0] +@420 +variables.ue0_rssi7[63:0] +variables.ue0_MCS7[63:0] +variables.ue0_RB7[63:0] +@24 +variables.ue0_ROUND7[63:0] +variables.ue0_SFN7[63:0] +@28 +functions.phy_enb_prach_rx +functions.phy_eNB_dlsch_encoding +functions.phy_eNB_dlsch_modulation +functions.phy_eNB_dlsch_scrambling +functions.phy_enb_pdcch_tx +functions.phy_enb_rs_tx +functions.rrc_mac_config_req +functions.rlc_data_req +functions.udp_enb_task +[pattern_trace] 1 +[pattern_trace] 0 From 727cdb4a871755f19399625bf4765ec223d9fa7e Mon Sep 17 00:00:00 2001 From: luhan wang Date: Thu, 27 Oct 2016 09:45:56 +0200 Subject: [PATCH 08/59] updates for udp IF4p5 --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 4 + targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c | 10 ++- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 74 ++++++++++--------- .../ETHERNET/USERSPACE/LIB/ethernet_lib.c | 74 ++++++++++++------- .../CONF/rcc.band7.tm1.50PRB.if4p5.conf | 4 +- targets/RT/USER/lte-enb.c | 12 ++- 7 files changed, 113 insertions(+), 67 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5e86d59378..c1507de61b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") -add_integer_option(MAX_NUM_CCs 1 "????") +add_integer_option(MAX_NUM_CCs 2 "????") add_boolean_option(MU_RECEIVER False "????") add_boolean_option(NEW_FFT True "????") add_boolean_option(OPENAIR1 True "????") diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 1176450ddb..1bf2f4b2d0 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -222,10 +222,14 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t 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; + printf("CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c index 126030d3d4..00500f2e02 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c @@ -311,6 +311,9 @@ 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); +#ifdef DEBUG + printf("Reading from device %p, eth %p, sockfd %d\n",device,eth,eth->sockfd[Mod_id]); +#endif bytes_received = recv(eth->sockfd[Mod_id], buff[0], @@ -321,7 +324,12 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam perror("ETHERNET IF4p5 READ (header): "); exit(-1); } - +#ifdef DEBUG + for (int i=0;isub_type; if (test_header->sub_type == IF4p5_PDLFFT) { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index 7d5fecbbf2..0e9f8d4730 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -54,9 +54,9 @@ #include "ethernet_lib.h" #define DEBUG 0 -struct sockaddr_in dest_addr[MAX_INST]; -struct sockaddr_in local_addr[MAX_INST]; -int addr_len[MAX_INST]; +//struct sockaddr_in dest_addr[MAX_INST]; +//struct sockaddr_in local_addr[MAX_INST]; +//int addr_len[MAX_INST]; uint16_t pck_seq_num = 1; @@ -96,7 +96,7 @@ int eth_socket_init_udp(openair0_device *device) { sock_type=SOCK_DGRAM; sock_proto=IPPROTO_UDP; - if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) { + if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) { perror("ETHERNET: Error opening socket"); exit(0); } @@ -107,32 +107,32 @@ int eth_socket_init_udp(openair0_device *device) { bzero((void *)&(local_addr[i]), sizeof(local_addr[i])); } - addr_len[Mod_id] = sizeof(struct sockaddr_in); + eth->udp.addr_len = sizeof(struct sockaddr_in); - dest_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,remote_ip,&(dest_addr[Mod_id].sin_addr.s_addr)); - dest_addr[Mod_id].sin_port=htons(remote_port); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str_remote, INET_ADDRSTRLEN); + eth->udp.dest_addr.sin_family = AF_INET; + inet_pton(AF_INET,remote_ip,&(dest_addr.sin_addr.s_addr)); + eth->udp.dest_addr.sin_port=htons(remote_port); + inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN); - local_addr[Mod_id].sin_family = AF_INET; - inet_pton(AF_INET,local_ip,&(local_addr[Mod_id].sin_addr.s_addr)); - local_addr[Mod_id].sin_port=htons(local_port); - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str_local, INET_ADDRSTRLEN); + device->local_addr.sin_family = AF_INET; + inet_pton(AF_INET,local_ip,&(device->local_addr.sin_addr.s_addr)); + device->local_addr.sin_port=htons(local_port); + inet_ntop(AF_INET, &(device->local_addr.sin_addr), str_local, INET_ADDRSTRLEN); /* set reuse address flag */ - if (setsockopt(eth->sockfd[Mod_id], SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); exit(0); } /* want to receive -> so bind */ - if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) { + if (bind(eth->sockfd,(struct sockaddr *)ð->udp.local_addr,addr_len[Mod_id])<0) { perror("ETHERNET: Cannot bind to socket"); exit(0); } else { - printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(local_addr[Mod_id].sin_port)); + printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(eth->udp.local_addr.sin_port)); } return 0; @@ -155,11 +155,11 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam while(bytes_received == -1) { again: - bytes_received = recvfrom(eth->sockfd[Mod_id], + bytes_received = recvfrom(eth->sockfd, buff[0], packet_size, 0, - (struct sockaddr *)&dest_addr[Mod_id], + (struct sockaddr *)ð->udp.dest_addr, (socklen_t *)&addr_len[Mod_id]); if (bytes_received ==-1) { eth->num_rx_errors++; @@ -223,11 +223,11 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam eth->tx_nsamps = nblocks; - bytes_sent = sendto(eth->sockfd[Mod_id], + bytes_sent = sendto(eth->sockfd, buff[0], packet_size, 0, - (struct sockaddr*)&dest_addr[Mod_id], + (struct sockaddr*)ð->udp.dest_addr, addr_len[Mod_id]); if (bytes_sent == -1) { @@ -280,11 +280,11 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi bytes_sent); #endif /* Send packet */ - bytes_sent += sendto(eth->sockfd[Mod_id], + bytes_sent += sendto(eth->sockfd, buff2, UDP_PACKET_SIZE_BYTES(nsamps), sendto_flag, - (struct sockaddr*)&dest_addr[Mod_id], + (struct sockaddr*)ð->udp.dest_addr, addr_len[Mod_id]); if ( bytes_sent == -1) { @@ -350,12 +350,12 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi UDP_PACKET_SIZE_BYTES(nsamps) - bytes_received, bytes_received); #endif - bytes_received +=recvfrom(eth->sockfd[Mod_id], + bytes_received +=recvfrom(eth->sockfd, buff2, UDP_PACKET_SIZE_BYTES(nsamps), rcvfrom_flag, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&addr_len[Mod_id]); + (struct sockaddr *)ð->udp.dest_addr, + (socklen_t *)&device->udp.addr_len); if (bytes_received ==-1) { eth->num_rx_errors++; @@ -437,9 +437,13 @@ int eth_set_dev_conf_udp(openair0_device *device) { msg=malloc(sizeof(openair0_config_t)); msg_len=sizeof(openair0_config_t); memcpy(msg,(void*)device->openair0_cfg,msg_len); + + printf("Sending configuration to device %p (%d.%d.%d.%d)\n",device, + eth->udp.dest_addr[3],eth->udp.dest_addr[2],eth->udp.dest_addr[1],eth->udp.dest_addr[0],msg_len); - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],addr_len[Mod_id])==-1) { + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->udp.dest_addr,device->udp.addr_len)==-1) { perror("ETHERNET: "); + printf("addr_len[%d] : %d, msg_len %d\n",Mod_id,device->udp.addr_len,msg_len); exit(0); } @@ -457,15 +461,15 @@ int eth_get_dev_conf_udp(openair0_device *device) { msg=malloc(sizeof(openair0_config_t)); msg_len=sizeof(openair0_config_t); - inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); - inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(eth->udp.local_addr.sin_addr), str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str1, INET_ADDRSTRLEN); /* RRH receives from BBU openair0_config_t */ - if (recvfrom(eth->sockfd[Mod_id], + if (recvfrom(eth->sockfd, msg, msg_len, 0, - (struct sockaddr *)&dest_addr[Mod_id], + (struct sockaddr *)ð->udp.dest_addr, (socklen_t *)&addr_len[Mod_id])==-1) { perror("ETHERNET: "); exit(0); @@ -473,15 +477,15 @@ int eth_get_dev_conf_udp(openair0_device *device) { device->openair0_cfg=(openair0_config_t *)msg; /* get remote ip address and port */ - /* inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->remote_port =ntohs(dest_addr[Mod_id].sin_port); */ + /* inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->remote_port =ntohs(eth->udp.dest_addr.sin_port); */ /* device->openair0_cfg->remote_addr =str1; */ /* /\* restore local ip address and port *\/ */ - /* inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->my_port =ntohs(local_addr[Mod_id].sin_port); */ + /* inet_ntop(AF_INET, &(eth->udp.local_addr.sin_addr), str, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->my_port =ntohs(eth->udp.local_addr.sin_port); */ /* device->openair0_cfg->my_addr =str; */ - /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd[Mod_id],str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ + /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ return 0; } diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 6079781ba1..b9900c3364 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -52,9 +52,9 @@ #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 num_devices_eth = 0; +//struct sockaddr_in dest_addr[MAX_INST]; +//int dest_addr_len[MAX_INST]; int trx_eth_start(openair0_device *device) { @@ -121,7 +121,7 @@ void trx_eth_end(openair0_device *device) { eth_state_t *eth = (eth_state_t*)device->priv; int Mod_id = device->Mod_id; /* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */ - if ( close(eth->sockfd[Mod_id]) <0 ) { + if ( close(eth->sockfd) <0 ) { perror("ETHERNET: Failed to close socket"); exit(0); } else { @@ -137,10 +137,17 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) { eth_state_t *eth = (eth_state_t*)device->priv; /* BBU sends a message to RRH */ - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],dest_addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } + + if ((eth->flags == ETH_RAW_MODE) || (eth->flags == ETH_RAW_IF4p5_MODE)) + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->raw.dest_addr,eth->raw.dest_addr_len)==-1) { + perror("ETHERNET: "); + exit(0); + } + else + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->udp.dest_addr,eth->udp.dest_addr_len)==-1) { + perror("ETHERNET: "); + exit(0); + } return 0; } @@ -152,16 +159,33 @@ int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) { int Mod_id = device->Mod_id; /* RRH receives from BBU a message */ - if (recvfrom(eth->sockfd[Mod_id], - msg, - msg_len, - 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&dest_addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - + + if ((eth->flags == ETH_RAW_MODE) || (eth->flags == ETH_RAW_IF4p5_MODE)) { + + if (recvfrom(eth->sockfd, + msg, + msg_len, + 0, + (struct sockaddr *)ð->raw.dest_addr, + (socklen_t *)ð->raw.dest_addr_len)==-1) { + perror("ETHERNET: "); + exit(0); + } + } + else { + if (recvfrom(eth->sockfd, + msg, + msg_len, + 0, + (struct sockaddr *)ð->udp.dest_addr, + (socklen_t *)ð->udp.dest_addr_len)==-1) { + perror("ETHERNET: "); + exit(0); + } + } + + + return 0; } @@ -204,7 +228,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { /****************** socket level options ************************/ switch(option) { case SND_BUF_SIZE: /* transmit socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_SNDBUF, &value,sizeof(value))) { @@ -215,7 +239,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { break; case RCV_BUF_SIZE: /* receive socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_RCVBUF, &value,sizeof(value))) { @@ -228,7 +252,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { case RCV_TIMEOUT: timeout.tv_sec = value/1000000; timeout.tv_usec = value%1000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof(timeout))) { @@ -241,7 +265,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { case SND_TIMEOUT: timeout.tv_sec = value/1000000000; timeout.tv_usec = value%1000000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,sizeof(timeout))) { @@ -257,7 +281,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); ifr.ifr_mtu =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFMTU,(caddr_t)&ifr) < 0 ) + if (ioctl(eth->sockfd,SIOCSIFMTU,(caddr_t)&ifr) < 0 ) perror ("[ETHERNET] Can't set the MTU"); else printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_mtu); @@ -267,7 +291,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); ifr.ifr_qlen =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) + if (ioctl(eth->sockfd,SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) perror ("[ETHERNET] Can't set the txqueuelen"); else printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_qlen); @@ -351,7 +375,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth } printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH")); - device->Mod_id = num_devices_eth++; + device->Mod_id = 0;//num_devices_eth++; device->transp_type = ETHERNET_TP; device->trx_start_func = trx_eth_start; device->trx_request_func = trx_eth_request; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf index 5fc097f0df..7890736e5e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf @@ -36,6 +36,7 @@ eNBs = Nid_cell = 0; N_RB_DL = 50; Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; tx_gain = 90; @@ -67,7 +68,7 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -102; + pusch_p0_Nominal = -96; pusch_alpha = "AL1"; pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; @@ -100,6 +101,7 @@ eNBs = ue_TimersAndConstants_t311 = 10000; ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; } ); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index fd5d38f696..25b816f4f1 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -981,11 +981,11 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); + LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); + LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); exit_fun("Exiting"); } } else { @@ -1276,7 +1276,8 @@ static void* eNB_thread_single( void* param ) { subframe++; } - LOG_D(PHY,"eNB Fronthaul thread, frame %d, subframe %d\n",frame,subframe); + LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", + pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe); // synchronization on FH interface, acquire signals/data and block if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe); @@ -1400,6 +1401,7 @@ void init_eNB_proc(int inst) { } //for multiple CCs: setup master and slaves + /* for (CC_id=0; CC_id= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc); } } - } + }*/ /* setup PHY proc TX sync mechanism */ @@ -1614,6 +1616,8 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->node_timing = node_timing[CC_id]; eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; + eNB->iframe_offset = -1; + eNB->isubframe_offset = -1; LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); switch (node_function[CC_id]) { From 5e1d462aa9b4d5110eaea35294e8b74b0c968cfd Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 27 Oct 2016 09:56:23 +0200 Subject: [PATCH 09/59] resynch for initial RF acqusition --- openair3/COMMON/as_message.h | 579 +++++++++++++++++- openair3/INTERTASK_INTERFACE | 1 - openair3/NAS/COMMON/API/NETWORK/as_message.h | 579 +++++++++++++++++- openair3/NAS/COMMON/commonDef.h | 343 ++++++++++- openair3/NAS/COMMON/networkDef.h | 279 ++++++++- .../rru.band7.tm1.50PRB.if5.usrpb210.conf | 6 +- .../rru.band7.tm1.if4p5.25PRB.usrpb210.conf | 6 +- .../rru.band7.tm1.if4p5.50PRB.usrpb210.conf | 17 +- targets/RT/USER/lte-enb.c | 12 + 9 files changed, 1804 insertions(+), 18 deletions(-) mode change 120000 => 100644 openair3/COMMON/as_message.h delete mode 120000 openair3/INTERTASK_INTERFACE mode change 120000 => 100644 openair3/NAS/COMMON/API/NETWORK/as_message.h mode change 120000 => 100644 openair3/NAS/COMMON/commonDef.h mode change 120000 => 100644 openair3/NAS/COMMON/networkDef.h diff --git a/openair3/COMMON/as_message.h b/openair3/COMMON/as_message.h deleted file mode 120000 index 3bfc76865a..0000000000 --- a/openair3/COMMON/as_message.h +++ /dev/null @@ -1 +0,0 @@ -../../openair2/COMMON/as_message.h \ No newline at end of file diff --git a/openair3/COMMON/as_message.h b/openair3/COMMON/as_message.h new file mode 100644 index 0000000000..30810a325e --- /dev/null +++ b/openair3/COMMON/as_message.h @@ -0,0 +1,578 @@ +/* + * Copyright (c) 2015, EURECOM (www.eurecom.fr) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the FreeBSD Project. + */ + + +/***************************************************************************** + +Source as_message.h + +Version 0.1 + +Date 2012/10/18 + +Product NAS stack + +Subsystem Application Programming Interface + +Author Frederic Maurel + +Description Defines the messages supported by the Access Stratum sublayer + protocol (usually RRC and S1AP for E-UTRAN) and functions used + to encode and decode + +*****************************************************************************/ +#ifndef __AS_MESSAGE_H__ +#define __AS_MESSAGE_H__ + +#include "commonDef.h" +#include "networkDef.h" + +/****************************************************************************/ +/********************* G L O B A L C O N S T A N T S *******************/ +/****************************************************************************/ + +/* + * -------------------------------------------------------------------------- + * Access Stratum message types + * -------------------------------------------------------------------------- + */ +#define AS_REQUEST 0x0100 +#define AS_RESPONSE 0x0200 +#define AS_INDICATION 0x0400 +#define AS_CONFIRM 0x0800 + +/* + * -------------------------------------------------------------------------- + * Access Stratum message identifiers + * -------------------------------------------------------------------------- + */ + +/* Broadcast information */ +#define AS_BROADCAST_INFO 0x01 +#define AS_BROADCAST_INFO_IND (AS_BROADCAST_INFO | AS_INDICATION) + +/* Cell information relevant for cell selection processing */ +#define AS_CELL_INFO 0x02 +#define AS_CELL_INFO_REQ (AS_CELL_INFO | AS_REQUEST) +#define AS_CELL_INFO_CNF (AS_CELL_INFO | AS_CONFIRM) +#define AS_CELL_INFO_IND (AS_CELL_INFO | AS_INDICATION) + +/* Paging information */ +#define AS_PAGING 0x03 +#define AS_PAGING_REQ (AS_PAGING | AS_REQUEST) +#define AS_PAGING_IND (AS_PAGING | AS_INDICATION) + +/* NAS signalling connection establishment */ +#define AS_NAS_ESTABLISH 0x04 +#define AS_NAS_ESTABLISH_REQ (AS_NAS_ESTABLISH | AS_REQUEST) +#define AS_NAS_ESTABLISH_IND (AS_NAS_ESTABLISH | AS_INDICATION) +#define AS_NAS_ESTABLISH_RSP (AS_NAS_ESTABLISH | AS_RESPONSE) +#define AS_NAS_ESTABLISH_CNF (AS_NAS_ESTABLISH | AS_CONFIRM) + +/* NAS signalling connection release */ +#define AS_NAS_RELEASE 0x05 +#define AS_NAS_RELEASE_REQ (AS_NAS_RELEASE | AS_REQUEST) +#define AS_NAS_RELEASE_IND (AS_NAS_RELEASE | AS_INDICATION) + +/* Uplink information transfer */ +#define AS_UL_INFO_TRANSFER 0x06 +#define AS_UL_INFO_TRANSFER_REQ (AS_UL_INFO_TRANSFER | AS_REQUEST) +#define AS_UL_INFO_TRANSFER_CNF (AS_UL_INFO_TRANSFER | AS_CONFIRM) +#define AS_UL_INFO_TRANSFER_IND (AS_UL_INFO_TRANSFER | AS_INDICATION) + +/* Downlink information transfer */ +#define AS_DL_INFO_TRANSFER 0x07 +#define AS_DL_INFO_TRANSFER_REQ (AS_DL_INFO_TRANSFER | AS_REQUEST) +#define AS_DL_INFO_TRANSFER_CNF (AS_DL_INFO_TRANSFER | AS_CONFIRM) +#define AS_DL_INFO_TRANSFER_IND (AS_DL_INFO_TRANSFER | AS_INDICATION) + +/* Radio Access Bearer establishment */ +#define AS_RAB_ESTABLISH 0x08 +#define AS_RAB_ESTABLISH_REQ (AS_RAB_ESTABLISH | AS_REQUEST) +#define AS_RAB_ESTABLISH_IND (AS_RAB_ESTABLISH | AS_INDICATION) +#define AS_RAB_ESTABLISH_RSP (AS_RAB_ESTABLISH | AS_RESPONSE) +#define AS_RAB_ESTABLISH_CNF (AS_RAB_ESTABLISH | AS_CONFIRM) + +/* Radio Access Bearer release */ +#define AS_RAB_RELEASE 0x09 +#define AS_RAB_RELEASE_REQ (AS_RAB_RELEASE | AS_REQUEST) +#define AS_RAB_RELEASE_IND (AS_RAB_RELEASE | AS_INDICATION) + +/* NAS Cause */ +#define EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED (8) +#define EPS_SERVICES_NOT_ALLOWED (7) +#define PLMN_NOT_ALLOWED (11) +#define TRACKING_AREA_NOT_ALLOWED (12) +#define ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA (13) +#define EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN (14) +#define NO_SUITABLE_CELLS_IN_TRACKING_AREA (15) +#define NETWORK_FAILURE (17) +#define ESM_FAILURE (19) + +typedef enum nas_cause_s { + NAS_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED, + NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_NOT_ALLOWED, + NAS_CAUSE_PLMN_NOT_ALLOWED = PLMN_NOT_ALLOWED, + NAS_CAUSE_TRACKING_AREA_NOT_ALLOWED = TRACKING_AREA_NOT_ALLOWED, + NAS_CAUSE_ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA = ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA, + NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN = EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN, + NAS_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA = NO_SUITABLE_CELLS_IN_TRACKING_AREA, + NAS_CAUSE_NETWORK_FAILURE = NETWORK_FAILURE, + NAS_CAUSE_ESM_FAILURE = ESM_FAILURE +} nas_cause_t; + +/* + * -------------------------------------------------------------------------- + * Access Stratum message global parameters + * -------------------------------------------------------------------------- + */ + +/* Error code */ +typedef enum nas_error_code_s { + AS_SUCCESS = 1, /* Success code, transaction is going on */ + AS_TERMINATED_NAS, /* Transaction terminated by NAS */ + AS_TERMINATED_AS, /* Transaction terminated by AS */ + AS_FAILURE /* Failure code */ +} nas_error_code_t; + +/* Core network domain */ +typedef enum core_network_s { + AS_PS = 1, /* Packet-Switched */ + AS_CS /* Circuit-Switched */ +} core_network_t; + +/* SAE Temporary Mobile Subscriber Identity */ +typedef struct as_stmsi_s { + uint8_t MMEcode; /* MME code that allocated the GUTI */ + uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */ +} as_stmsi_t; + +/* Dedicated NAS information */ +typedef struct as_nas_info_s { + uint32_t length; /* Length of the NAS information data */ + Byte_t* data; /* Dedicated NAS information data container */ +} as_nas_info_t; + +/* Radio Access Bearer identity */ +typedef uint8_t as_rab_id_t; + +/****************************************************************************/ +/************************ G L O B A L T Y P E S ************************/ +/****************************************************************************/ + +/* + * -------------------------------------------------------------------------- + * Broadcast information + * -------------------------------------------------------------------------- + */ + +/* + * AS->NAS - Broadcast information indication + * AS may asynchronously report to NAS available PLMNs within specific + * location area + */ +typedef struct broadcast_info_ind_s { +#define PLMN_LIST_MAX_SIZE 6 + PLMN_LIST_T(PLMN_LIST_MAX_SIZE) plmnIDs; /* List of PLMN identifiers */ + ci_t cellID; /* Identity of the cell serving the listed PLMNs */ + tac_t tac; /* Code of the tracking area the cell belongs to */ +} broadcast_info_ind_t; + +/* + * -------------------------------------------------------------------------- + * Cell information relevant for cell selection processing + * -------------------------------------------------------------------------- + */ + +/* Radio access technologies supported by the network */ +#define AS_GSM (1 << NET_ACCESS_GSM) +#define AS_COMPACT (1 << NET_ACCESS_COMPACT) +#define AS_UTRAN (1 << NET_ACCESS_UTRAN) +#define AS_EGPRS (1 << NET_ACCESS_EGPRS) +#define AS_HSDPA (1 << NET_ACCESS_HSDPA) +#define AS_HSUPA (1 << NET_ACCESS_HSUPA) +#define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) +#define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) + +/* + * NAS->AS - Cell Information request + * NAS request AS to search for a suitable cell belonging to the selected + * PLMN to camp on. + */ +typedef struct cell_info_req_s { + plmn_t plmnID; /* Selected PLMN identity */ + Byte_t rat; /* Bitmap - set of radio access technologies */ +} cell_info_req_t; + +/* + * AS->NAS - Cell Information confirm + * AS search for a suitable cell and respond to NAS. If found, the cell + * is selected to camp on. + */ +typedef struct cell_info_cnf_s { + uint8_t errCode; /* Error code */ + ci_t cellID; /* Identity of the cell serving the selected PLMN */ + tac_t tac; /* Code of the tracking area the cell belongs to */ + AcT_t rat; /* Radio access technology supported by the cell */ + uint8_t rsrq; /* Reference signal received quality */ + uint8_t rsrp; /* Reference signal received power */ +} cell_info_cnf_t; + +/* + * AS->NAS - Cell Information indication + * AS may change cell selection if a more suitable cell is found. + */ +typedef struct cell_info_ind_s { + ci_t cellID; /* Identity of the new serving cell */ + tac_t tac; /* Code of the tracking area the cell belongs to */ +} cell_info_ind_t; + +/* + * -------------------------------------------------------------------------- + * Paging information + * -------------------------------------------------------------------------- + */ + +/* Paging cause */ +typedef enum paging_cause_s { + AS_CONNECTION_ESTABLISH, /* Establish NAS signalling connection */ + AS_EPS_ATTACH, /* Perform local detach and initiate EPS + * attach procedure */ + AS_CS_FALLBACK /* Inititate CS fallback procedure */ +} paging_cause_t; + +/* + * NAS->AS - Paging Information request + * NAS requests the AS that NAS signalling messages or user data is pending + * to be sent. + */ +typedef struct paging_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + uint8_t CN_domain; /* Core network domain */ +} paging_req_t; + +/* + * AS->NAS - Paging Information indication + * AS reports to the NAS that appropriate procedure has to be initiated. + */ +typedef struct paging_ind_s { + paging_cause_t cause; /* Paging cause */ +} paging_ind_t; + +/* + * -------------------------------------------------------------------------- + * NAS signalling connection establishment + * -------------------------------------------------------------------------- + */ + +/* Cause of RRC connection establishment */ +typedef enum as_cause_s { + AS_CAUSE_UNKNOWN = 0, + AS_CAUSE_EMERGENCY = NET_ESTABLISH_CAUSE_EMERGENCY, + AS_CAUSE_HIGH_PRIO = NET_ESTABLISH_CAUSE_HIGH_PRIO, + AS_CAUSE_MT_ACCESS = NET_ESTABLISH_CAUSE_MT_ACCESS, + AS_CAUSE_MO_SIGNAL = NET_ESTABLISH_CAUSE_MO_SIGNAL, + AS_CAUSE_MO_DATA = NET_ESTABLISH_CAUSE_MO_DATA, + AS_CAUSE_V1020 = NET_ESTABLISH_CAUSE_V1020 +} as_cause_t; + +/* Type of the call associated to the RRC connection establishment */ +typedef enum as_call_type_s { + AS_TYPE_ORIGINATING_SIGNAL = NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL, + AS_TYPE_EMERGENCY_CALLS = NET_ESTABLISH_TYPE_EMERGENCY_CALLS, + AS_TYPE_ORIGINATING_CALLS = NET_ESTABLISH_TYPE_ORIGINATING_CALLS, + AS_TYPE_TERMINATING_CALLS = NET_ESTABLISH_TYPE_TERMINATING_CALLS, + AS_TYPE_MO_CS_FALLBACK = NET_ESTABLISH_TYPE_MO_CS_FALLBACK +} as_call_type_t; + +/* + * NAS->AS - NAS signalling connection establishment request + * NAS requests the AS to perform the RRC connection establishment procedure + * to transfer initial NAS message to the network while UE is in IDLE mode. + */ +typedef struct nas_establish_req_s { + as_cause_t cause; /* RRC connection establishment cause */ + as_call_type_t type; /* RRC associated call type */ + as_stmsi_t s_tmsi; /* UE identity */ + plmn_t plmnID; /* Selected PLMN identity */ + as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ +} nas_establish_req_t; + +/* + * AS->NAS - NAS signalling connection establishment indication + * AS transfers the initial NAS message to the NAS. + */ +typedef struct nas_establish_ind_s { + uint32_t UEid; /* UE lower layer identifier */ + tac_t tac; /* Code of the tracking area the initiating + * UE belongs to */ + as_cause_t asCause; /* Establishment cause */ + as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ +} nas_establish_ind_t; + +/* + * NAS->AS - NAS signalling connection establishment response + * NAS responds to the AS that initial answer message has to be provided to + * the UE. + */ +typedef struct nas_establish_rsp_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + nas_error_code_t errCode; /* Transaction status */ + as_nas_info_t nasMsg; /* NAS message to transfer */ + uint32_t nas_ul_count; /* UL NAS COUNT */ + uint16_t selected_encryption_algorithm; + uint16_t selected_integrity_algorithm; +} nas_establish_rsp_t; + +/* + * AS->NAS - NAS signalling connection establishment confirm + * AS transfers the initial answer message to the NAS. + */ +typedef struct nas_establish_cnf_s { + uint32_t UEid; /* UE lower layer identifier */ + nas_error_code_t errCode; /* Transaction status */ + as_nas_info_t nasMsg; /* NAS message to transfer */ + uint32_t ul_nas_count; + uint16_t selected_encryption_algorithm; + uint16_t selected_integrity_algorithm; +} nas_establish_cnf_t; + +/* + * -------------------------------------------------------------------------- + * NAS signalling connection release + * -------------------------------------------------------------------------- + */ + +/* Release cause */ +typedef enum release_cause_s { + AS_AUTHENTICATION_FAILURE = 1, /* Authentication procedure failed */ + AS_DETACH /* Detach requested */ +} release_cause_t; + +/* + * NAS->AS - NAS signalling connection release request + * NAS requests the termination of the connection with the UE. + */ +typedef struct nas_release_req_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + release_cause_t cause; /* Release cause */ +} nas_release_req_t; + +/* + * AS->NAS - NAS signalling connection release indication + * AS reports that connection has been terminated by the network. + */ +typedef struct nas_release_ind_s { + release_cause_t cause; /* Release cause */ +} nas_release_ind_t; + +/* + * -------------------------------------------------------------------------- + * NAS information transfer + * -------------------------------------------------------------------------- + */ + +/* + * NAS->AS - Uplink data transfer request + * NAS requests the AS to transfer uplink information to the NAS that + * operates at the network side. + */ +typedef struct ul_info_transfer_req_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + as_nas_info_t nasMsg; /* Uplink NAS message */ +} ul_info_transfer_req_t; + +/* + * AS->NAS - Uplink data transfer confirm + * AS immediately notifies the NAS whether uplink information has been + * successfully sent to the network or not. + */ +typedef struct ul_info_transfer_cnf_s { + uint32_t UEid; /* UE lower layer identifier */ + nas_error_code_t errCode; /* Transaction status */ +} ul_info_transfer_cnf_t; + +/* + * AS->NAS - Uplink data transfer indication + * AS delivers the uplink information message to the NAS that operates + * at the network side. + */ +typedef struct ul_info_transfer_ind_s { + uint32_t UEid; /* UE lower layer identifier */ + as_nas_info_t nasMsg; /* Uplink NAS message */ +} ul_info_transfer_ind_t; + +/* + * NAS->AS - Downlink data transfer request + * NAS requests the AS to transfer downlink information to the NAS that + * operates at the UE side. + */ +typedef ul_info_transfer_req_t dl_info_transfer_req_t; + +/* + * AS->NAS - Downlink data transfer confirm + * AS immediately notifies the NAS whether downlink information has been + * successfully sent to the network or not. + */ +typedef ul_info_transfer_cnf_t dl_info_transfer_cnf_t; + +/* + * AS->NAS - Downlink data transfer indication + * AS delivers the downlink information message to the NAS that operates + * at the UE side. + */ +typedef ul_info_transfer_ind_t dl_info_transfer_ind_t; + +/* + * -------------------------------------------------------------------------- + * Radio Access Bearer establishment + * -------------------------------------------------------------------------- + */ + +/* TODO: Quality of Service parameters */ +typedef struct {} as_qos_t; + +/* + * NAS->AS - Radio access bearer establishment request + * NAS requests the AS to allocate transmission resources to radio access + * bearer initialized at the network side. + */ +typedef struct rab_establish_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ + as_qos_t QoS; /* Requested Quality of Service */ +} rab_establish_req_t; + +/* + * AS->NAS - Radio access bearer establishment indication + * AS notifies the NAS that specific radio access bearer has to be setup. + */ +typedef struct rab_establish_ind_s { + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_establish_ind_t; + +/* + * NAS->AS - Radio access bearer establishment response + * NAS responds to AS whether the specified radio access bearer has been + * successfully setup or not. + */ +typedef struct rab_establish_rsp_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ + nas_error_code_t errCode; /* Transaction status */ +} rab_establish_rsp_t; + +/* + * AS->NAS - Radio access bearer establishment confirm + * AS notifies NAS whether the specified radio access bearer has been + * successfully setup at the UE side or not. + */ +typedef struct rab_establish_cnf_s { + as_rab_id_t rabID; /* Radio access bearer identity */ + nas_error_code_t errCode; /* Transaction status */ +} rab_establish_cnf_t; + +/* + * -------------------------------------------------------------------------- + * Radio Access Bearer release + * -------------------------------------------------------------------------- + */ + +/* + * NAS->AS - Radio access bearer release request + * NAS requests the AS to release transmission resources previously allocated + * to specific radio access bearer at the network side. + */ +typedef struct rab_release_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_release_req_t; + +/* + * AS->NAS - Radio access bearer release indication + * AS notifies NAS that specific radio access bearer has been released. + */ +typedef struct rab_release_ind_s { + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_release_ind_t; + +/* + * -------------------------------------------------------------------------- + * Structure of the AS messages handled by the network sublayer + * -------------------------------------------------------------------------- + */ +typedef struct as_message_s { + uint16_t msgID; + union { + broadcast_info_ind_t broadcast_info_ind; + cell_info_req_t cell_info_req; + cell_info_cnf_t cell_info_cnf; + cell_info_ind_t cell_info_ind; + paging_req_t paging_req; + paging_ind_t paging_ind; + nas_establish_req_t nas_establish_req; + nas_establish_ind_t nas_establish_ind; + nas_establish_rsp_t nas_establish_rsp; + nas_establish_cnf_t nas_establish_cnf; + nas_release_req_t nas_release_req; + nas_release_ind_t nas_release_ind; + ul_info_transfer_req_t ul_info_transfer_req; + ul_info_transfer_cnf_t ul_info_transfer_cnf; + ul_info_transfer_ind_t ul_info_transfer_ind; + dl_info_transfer_req_t dl_info_transfer_req; + dl_info_transfer_cnf_t dl_info_transfer_cnf; + dl_info_transfer_ind_t dl_info_transfer_ind; + rab_establish_req_t rab_establish_req; + rab_establish_ind_t rab_establish_ind; + rab_establish_rsp_t rab_establish_rsp; + rab_establish_cnf_t rab_establish_cnf; + rab_release_req_t rab_release_req; + rab_release_ind_t rab_release_ind; + } __attribute__((__packed__)) msg; +} as_message_t; + +/****************************************************************************/ +/******************** G L O B A L V A R I A B L E S ********************/ +/****************************************************************************/ + +/****************************************************************************/ +/****************** E X P O R T E D F U N C T I O N S ******************/ +/****************************************************************************/ + +int as_message_decode(const char* buffer, as_message_t* msg, int length); + +int as_message_encode(char* buffer, as_message_t* msg, int length); + +/* Implemented in the network_api.c body file */ +int as_message_send(as_message_t* as_msg); + +#endif /* __AS_MESSAGE_H__*/ diff --git a/openair3/INTERTASK_INTERFACE b/openair3/INTERTASK_INTERFACE deleted file mode 120000 index 4bc54522d8..0000000000 --- a/openair3/INTERTASK_INTERFACE +++ /dev/null @@ -1 +0,0 @@ -../common/utils/itti \ No newline at end of file diff --git a/openair3/NAS/COMMON/API/NETWORK/as_message.h b/openair3/NAS/COMMON/API/NETWORK/as_message.h deleted file mode 120000 index ef8d3686fd..0000000000 --- a/openair3/NAS/COMMON/API/NETWORK/as_message.h +++ /dev/null @@ -1 +0,0 @@ -../../../../../openair2/COMMON/as_message.h \ No newline at end of file diff --git a/openair3/NAS/COMMON/API/NETWORK/as_message.h b/openair3/NAS/COMMON/API/NETWORK/as_message.h new file mode 100644 index 0000000000..30810a325e --- /dev/null +++ b/openair3/NAS/COMMON/API/NETWORK/as_message.h @@ -0,0 +1,578 @@ +/* + * Copyright (c) 2015, EURECOM (www.eurecom.fr) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the FreeBSD Project. + */ + + +/***************************************************************************** + +Source as_message.h + +Version 0.1 + +Date 2012/10/18 + +Product NAS stack + +Subsystem Application Programming Interface + +Author Frederic Maurel + +Description Defines the messages supported by the Access Stratum sublayer + protocol (usually RRC and S1AP for E-UTRAN) and functions used + to encode and decode + +*****************************************************************************/ +#ifndef __AS_MESSAGE_H__ +#define __AS_MESSAGE_H__ + +#include "commonDef.h" +#include "networkDef.h" + +/****************************************************************************/ +/********************* G L O B A L C O N S T A N T S *******************/ +/****************************************************************************/ + +/* + * -------------------------------------------------------------------------- + * Access Stratum message types + * -------------------------------------------------------------------------- + */ +#define AS_REQUEST 0x0100 +#define AS_RESPONSE 0x0200 +#define AS_INDICATION 0x0400 +#define AS_CONFIRM 0x0800 + +/* + * -------------------------------------------------------------------------- + * Access Stratum message identifiers + * -------------------------------------------------------------------------- + */ + +/* Broadcast information */ +#define AS_BROADCAST_INFO 0x01 +#define AS_BROADCAST_INFO_IND (AS_BROADCAST_INFO | AS_INDICATION) + +/* Cell information relevant for cell selection processing */ +#define AS_CELL_INFO 0x02 +#define AS_CELL_INFO_REQ (AS_CELL_INFO | AS_REQUEST) +#define AS_CELL_INFO_CNF (AS_CELL_INFO | AS_CONFIRM) +#define AS_CELL_INFO_IND (AS_CELL_INFO | AS_INDICATION) + +/* Paging information */ +#define AS_PAGING 0x03 +#define AS_PAGING_REQ (AS_PAGING | AS_REQUEST) +#define AS_PAGING_IND (AS_PAGING | AS_INDICATION) + +/* NAS signalling connection establishment */ +#define AS_NAS_ESTABLISH 0x04 +#define AS_NAS_ESTABLISH_REQ (AS_NAS_ESTABLISH | AS_REQUEST) +#define AS_NAS_ESTABLISH_IND (AS_NAS_ESTABLISH | AS_INDICATION) +#define AS_NAS_ESTABLISH_RSP (AS_NAS_ESTABLISH | AS_RESPONSE) +#define AS_NAS_ESTABLISH_CNF (AS_NAS_ESTABLISH | AS_CONFIRM) + +/* NAS signalling connection release */ +#define AS_NAS_RELEASE 0x05 +#define AS_NAS_RELEASE_REQ (AS_NAS_RELEASE | AS_REQUEST) +#define AS_NAS_RELEASE_IND (AS_NAS_RELEASE | AS_INDICATION) + +/* Uplink information transfer */ +#define AS_UL_INFO_TRANSFER 0x06 +#define AS_UL_INFO_TRANSFER_REQ (AS_UL_INFO_TRANSFER | AS_REQUEST) +#define AS_UL_INFO_TRANSFER_CNF (AS_UL_INFO_TRANSFER | AS_CONFIRM) +#define AS_UL_INFO_TRANSFER_IND (AS_UL_INFO_TRANSFER | AS_INDICATION) + +/* Downlink information transfer */ +#define AS_DL_INFO_TRANSFER 0x07 +#define AS_DL_INFO_TRANSFER_REQ (AS_DL_INFO_TRANSFER | AS_REQUEST) +#define AS_DL_INFO_TRANSFER_CNF (AS_DL_INFO_TRANSFER | AS_CONFIRM) +#define AS_DL_INFO_TRANSFER_IND (AS_DL_INFO_TRANSFER | AS_INDICATION) + +/* Radio Access Bearer establishment */ +#define AS_RAB_ESTABLISH 0x08 +#define AS_RAB_ESTABLISH_REQ (AS_RAB_ESTABLISH | AS_REQUEST) +#define AS_RAB_ESTABLISH_IND (AS_RAB_ESTABLISH | AS_INDICATION) +#define AS_RAB_ESTABLISH_RSP (AS_RAB_ESTABLISH | AS_RESPONSE) +#define AS_RAB_ESTABLISH_CNF (AS_RAB_ESTABLISH | AS_CONFIRM) + +/* Radio Access Bearer release */ +#define AS_RAB_RELEASE 0x09 +#define AS_RAB_RELEASE_REQ (AS_RAB_RELEASE | AS_REQUEST) +#define AS_RAB_RELEASE_IND (AS_RAB_RELEASE | AS_INDICATION) + +/* NAS Cause */ +#define EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED (8) +#define EPS_SERVICES_NOT_ALLOWED (7) +#define PLMN_NOT_ALLOWED (11) +#define TRACKING_AREA_NOT_ALLOWED (12) +#define ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA (13) +#define EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN (14) +#define NO_SUITABLE_CELLS_IN_TRACKING_AREA (15) +#define NETWORK_FAILURE (17) +#define ESM_FAILURE (19) + +typedef enum nas_cause_s { + NAS_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED, + NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_NOT_ALLOWED, + NAS_CAUSE_PLMN_NOT_ALLOWED = PLMN_NOT_ALLOWED, + NAS_CAUSE_TRACKING_AREA_NOT_ALLOWED = TRACKING_AREA_NOT_ALLOWED, + NAS_CAUSE_ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA = ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA, + NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN = EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN, + NAS_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA = NO_SUITABLE_CELLS_IN_TRACKING_AREA, + NAS_CAUSE_NETWORK_FAILURE = NETWORK_FAILURE, + NAS_CAUSE_ESM_FAILURE = ESM_FAILURE +} nas_cause_t; + +/* + * -------------------------------------------------------------------------- + * Access Stratum message global parameters + * -------------------------------------------------------------------------- + */ + +/* Error code */ +typedef enum nas_error_code_s { + AS_SUCCESS = 1, /* Success code, transaction is going on */ + AS_TERMINATED_NAS, /* Transaction terminated by NAS */ + AS_TERMINATED_AS, /* Transaction terminated by AS */ + AS_FAILURE /* Failure code */ +} nas_error_code_t; + +/* Core network domain */ +typedef enum core_network_s { + AS_PS = 1, /* Packet-Switched */ + AS_CS /* Circuit-Switched */ +} core_network_t; + +/* SAE Temporary Mobile Subscriber Identity */ +typedef struct as_stmsi_s { + uint8_t MMEcode; /* MME code that allocated the GUTI */ + uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */ +} as_stmsi_t; + +/* Dedicated NAS information */ +typedef struct as_nas_info_s { + uint32_t length; /* Length of the NAS information data */ + Byte_t* data; /* Dedicated NAS information data container */ +} as_nas_info_t; + +/* Radio Access Bearer identity */ +typedef uint8_t as_rab_id_t; + +/****************************************************************************/ +/************************ G L O B A L T Y P E S ************************/ +/****************************************************************************/ + +/* + * -------------------------------------------------------------------------- + * Broadcast information + * -------------------------------------------------------------------------- + */ + +/* + * AS->NAS - Broadcast information indication + * AS may asynchronously report to NAS available PLMNs within specific + * location area + */ +typedef struct broadcast_info_ind_s { +#define PLMN_LIST_MAX_SIZE 6 + PLMN_LIST_T(PLMN_LIST_MAX_SIZE) plmnIDs; /* List of PLMN identifiers */ + ci_t cellID; /* Identity of the cell serving the listed PLMNs */ + tac_t tac; /* Code of the tracking area the cell belongs to */ +} broadcast_info_ind_t; + +/* + * -------------------------------------------------------------------------- + * Cell information relevant for cell selection processing + * -------------------------------------------------------------------------- + */ + +/* Radio access technologies supported by the network */ +#define AS_GSM (1 << NET_ACCESS_GSM) +#define AS_COMPACT (1 << NET_ACCESS_COMPACT) +#define AS_UTRAN (1 << NET_ACCESS_UTRAN) +#define AS_EGPRS (1 << NET_ACCESS_EGPRS) +#define AS_HSDPA (1 << NET_ACCESS_HSDPA) +#define AS_HSUPA (1 << NET_ACCESS_HSUPA) +#define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) +#define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) + +/* + * NAS->AS - Cell Information request + * NAS request AS to search for a suitable cell belonging to the selected + * PLMN to camp on. + */ +typedef struct cell_info_req_s { + plmn_t plmnID; /* Selected PLMN identity */ + Byte_t rat; /* Bitmap - set of radio access technologies */ +} cell_info_req_t; + +/* + * AS->NAS - Cell Information confirm + * AS search for a suitable cell and respond to NAS. If found, the cell + * is selected to camp on. + */ +typedef struct cell_info_cnf_s { + uint8_t errCode; /* Error code */ + ci_t cellID; /* Identity of the cell serving the selected PLMN */ + tac_t tac; /* Code of the tracking area the cell belongs to */ + AcT_t rat; /* Radio access technology supported by the cell */ + uint8_t rsrq; /* Reference signal received quality */ + uint8_t rsrp; /* Reference signal received power */ +} cell_info_cnf_t; + +/* + * AS->NAS - Cell Information indication + * AS may change cell selection if a more suitable cell is found. + */ +typedef struct cell_info_ind_s { + ci_t cellID; /* Identity of the new serving cell */ + tac_t tac; /* Code of the tracking area the cell belongs to */ +} cell_info_ind_t; + +/* + * -------------------------------------------------------------------------- + * Paging information + * -------------------------------------------------------------------------- + */ + +/* Paging cause */ +typedef enum paging_cause_s { + AS_CONNECTION_ESTABLISH, /* Establish NAS signalling connection */ + AS_EPS_ATTACH, /* Perform local detach and initiate EPS + * attach procedure */ + AS_CS_FALLBACK /* Inititate CS fallback procedure */ +} paging_cause_t; + +/* + * NAS->AS - Paging Information request + * NAS requests the AS that NAS signalling messages or user data is pending + * to be sent. + */ +typedef struct paging_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + uint8_t CN_domain; /* Core network domain */ +} paging_req_t; + +/* + * AS->NAS - Paging Information indication + * AS reports to the NAS that appropriate procedure has to be initiated. + */ +typedef struct paging_ind_s { + paging_cause_t cause; /* Paging cause */ +} paging_ind_t; + +/* + * -------------------------------------------------------------------------- + * NAS signalling connection establishment + * -------------------------------------------------------------------------- + */ + +/* Cause of RRC connection establishment */ +typedef enum as_cause_s { + AS_CAUSE_UNKNOWN = 0, + AS_CAUSE_EMERGENCY = NET_ESTABLISH_CAUSE_EMERGENCY, + AS_CAUSE_HIGH_PRIO = NET_ESTABLISH_CAUSE_HIGH_PRIO, + AS_CAUSE_MT_ACCESS = NET_ESTABLISH_CAUSE_MT_ACCESS, + AS_CAUSE_MO_SIGNAL = NET_ESTABLISH_CAUSE_MO_SIGNAL, + AS_CAUSE_MO_DATA = NET_ESTABLISH_CAUSE_MO_DATA, + AS_CAUSE_V1020 = NET_ESTABLISH_CAUSE_V1020 +} as_cause_t; + +/* Type of the call associated to the RRC connection establishment */ +typedef enum as_call_type_s { + AS_TYPE_ORIGINATING_SIGNAL = NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL, + AS_TYPE_EMERGENCY_CALLS = NET_ESTABLISH_TYPE_EMERGENCY_CALLS, + AS_TYPE_ORIGINATING_CALLS = NET_ESTABLISH_TYPE_ORIGINATING_CALLS, + AS_TYPE_TERMINATING_CALLS = NET_ESTABLISH_TYPE_TERMINATING_CALLS, + AS_TYPE_MO_CS_FALLBACK = NET_ESTABLISH_TYPE_MO_CS_FALLBACK +} as_call_type_t; + +/* + * NAS->AS - NAS signalling connection establishment request + * NAS requests the AS to perform the RRC connection establishment procedure + * to transfer initial NAS message to the network while UE is in IDLE mode. + */ +typedef struct nas_establish_req_s { + as_cause_t cause; /* RRC connection establishment cause */ + as_call_type_t type; /* RRC associated call type */ + as_stmsi_t s_tmsi; /* UE identity */ + plmn_t plmnID; /* Selected PLMN identity */ + as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ +} nas_establish_req_t; + +/* + * AS->NAS - NAS signalling connection establishment indication + * AS transfers the initial NAS message to the NAS. + */ +typedef struct nas_establish_ind_s { + uint32_t UEid; /* UE lower layer identifier */ + tac_t tac; /* Code of the tracking area the initiating + * UE belongs to */ + as_cause_t asCause; /* Establishment cause */ + as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ +} nas_establish_ind_t; + +/* + * NAS->AS - NAS signalling connection establishment response + * NAS responds to the AS that initial answer message has to be provided to + * the UE. + */ +typedef struct nas_establish_rsp_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + nas_error_code_t errCode; /* Transaction status */ + as_nas_info_t nasMsg; /* NAS message to transfer */ + uint32_t nas_ul_count; /* UL NAS COUNT */ + uint16_t selected_encryption_algorithm; + uint16_t selected_integrity_algorithm; +} nas_establish_rsp_t; + +/* + * AS->NAS - NAS signalling connection establishment confirm + * AS transfers the initial answer message to the NAS. + */ +typedef struct nas_establish_cnf_s { + uint32_t UEid; /* UE lower layer identifier */ + nas_error_code_t errCode; /* Transaction status */ + as_nas_info_t nasMsg; /* NAS message to transfer */ + uint32_t ul_nas_count; + uint16_t selected_encryption_algorithm; + uint16_t selected_integrity_algorithm; +} nas_establish_cnf_t; + +/* + * -------------------------------------------------------------------------- + * NAS signalling connection release + * -------------------------------------------------------------------------- + */ + +/* Release cause */ +typedef enum release_cause_s { + AS_AUTHENTICATION_FAILURE = 1, /* Authentication procedure failed */ + AS_DETACH /* Detach requested */ +} release_cause_t; + +/* + * NAS->AS - NAS signalling connection release request + * NAS requests the termination of the connection with the UE. + */ +typedef struct nas_release_req_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + release_cause_t cause; /* Release cause */ +} nas_release_req_t; + +/* + * AS->NAS - NAS signalling connection release indication + * AS reports that connection has been terminated by the network. + */ +typedef struct nas_release_ind_s { + release_cause_t cause; /* Release cause */ +} nas_release_ind_t; + +/* + * -------------------------------------------------------------------------- + * NAS information transfer + * -------------------------------------------------------------------------- + */ + +/* + * NAS->AS - Uplink data transfer request + * NAS requests the AS to transfer uplink information to the NAS that + * operates at the network side. + */ +typedef struct ul_info_transfer_req_s { + uint32_t UEid; /* UE lower layer identifier */ + as_stmsi_t s_tmsi; /* UE identity */ + as_nas_info_t nasMsg; /* Uplink NAS message */ +} ul_info_transfer_req_t; + +/* + * AS->NAS - Uplink data transfer confirm + * AS immediately notifies the NAS whether uplink information has been + * successfully sent to the network or not. + */ +typedef struct ul_info_transfer_cnf_s { + uint32_t UEid; /* UE lower layer identifier */ + nas_error_code_t errCode; /* Transaction status */ +} ul_info_transfer_cnf_t; + +/* + * AS->NAS - Uplink data transfer indication + * AS delivers the uplink information message to the NAS that operates + * at the network side. + */ +typedef struct ul_info_transfer_ind_s { + uint32_t UEid; /* UE lower layer identifier */ + as_nas_info_t nasMsg; /* Uplink NAS message */ +} ul_info_transfer_ind_t; + +/* + * NAS->AS - Downlink data transfer request + * NAS requests the AS to transfer downlink information to the NAS that + * operates at the UE side. + */ +typedef ul_info_transfer_req_t dl_info_transfer_req_t; + +/* + * AS->NAS - Downlink data transfer confirm + * AS immediately notifies the NAS whether downlink information has been + * successfully sent to the network or not. + */ +typedef ul_info_transfer_cnf_t dl_info_transfer_cnf_t; + +/* + * AS->NAS - Downlink data transfer indication + * AS delivers the downlink information message to the NAS that operates + * at the UE side. + */ +typedef ul_info_transfer_ind_t dl_info_transfer_ind_t; + +/* + * -------------------------------------------------------------------------- + * Radio Access Bearer establishment + * -------------------------------------------------------------------------- + */ + +/* TODO: Quality of Service parameters */ +typedef struct {} as_qos_t; + +/* + * NAS->AS - Radio access bearer establishment request + * NAS requests the AS to allocate transmission resources to radio access + * bearer initialized at the network side. + */ +typedef struct rab_establish_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ + as_qos_t QoS; /* Requested Quality of Service */ +} rab_establish_req_t; + +/* + * AS->NAS - Radio access bearer establishment indication + * AS notifies the NAS that specific radio access bearer has to be setup. + */ +typedef struct rab_establish_ind_s { + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_establish_ind_t; + +/* + * NAS->AS - Radio access bearer establishment response + * NAS responds to AS whether the specified radio access bearer has been + * successfully setup or not. + */ +typedef struct rab_establish_rsp_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ + nas_error_code_t errCode; /* Transaction status */ +} rab_establish_rsp_t; + +/* + * AS->NAS - Radio access bearer establishment confirm + * AS notifies NAS whether the specified radio access bearer has been + * successfully setup at the UE side or not. + */ +typedef struct rab_establish_cnf_s { + as_rab_id_t rabID; /* Radio access bearer identity */ + nas_error_code_t errCode; /* Transaction status */ +} rab_establish_cnf_t; + +/* + * -------------------------------------------------------------------------- + * Radio Access Bearer release + * -------------------------------------------------------------------------- + */ + +/* + * NAS->AS - Radio access bearer release request + * NAS requests the AS to release transmission resources previously allocated + * to specific radio access bearer at the network side. + */ +typedef struct rab_release_req_s { + as_stmsi_t s_tmsi; /* UE identity */ + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_release_req_t; + +/* + * AS->NAS - Radio access bearer release indication + * AS notifies NAS that specific radio access bearer has been released. + */ +typedef struct rab_release_ind_s { + as_rab_id_t rabID; /* Radio access bearer identity */ +} rab_release_ind_t; + +/* + * -------------------------------------------------------------------------- + * Structure of the AS messages handled by the network sublayer + * -------------------------------------------------------------------------- + */ +typedef struct as_message_s { + uint16_t msgID; + union { + broadcast_info_ind_t broadcast_info_ind; + cell_info_req_t cell_info_req; + cell_info_cnf_t cell_info_cnf; + cell_info_ind_t cell_info_ind; + paging_req_t paging_req; + paging_ind_t paging_ind; + nas_establish_req_t nas_establish_req; + nas_establish_ind_t nas_establish_ind; + nas_establish_rsp_t nas_establish_rsp; + nas_establish_cnf_t nas_establish_cnf; + nas_release_req_t nas_release_req; + nas_release_ind_t nas_release_ind; + ul_info_transfer_req_t ul_info_transfer_req; + ul_info_transfer_cnf_t ul_info_transfer_cnf; + ul_info_transfer_ind_t ul_info_transfer_ind; + dl_info_transfer_req_t dl_info_transfer_req; + dl_info_transfer_cnf_t dl_info_transfer_cnf; + dl_info_transfer_ind_t dl_info_transfer_ind; + rab_establish_req_t rab_establish_req; + rab_establish_ind_t rab_establish_ind; + rab_establish_rsp_t rab_establish_rsp; + rab_establish_cnf_t rab_establish_cnf; + rab_release_req_t rab_release_req; + rab_release_ind_t rab_release_ind; + } __attribute__((__packed__)) msg; +} as_message_t; + +/****************************************************************************/ +/******************** G L O B A L V A R I A B L E S ********************/ +/****************************************************************************/ + +/****************************************************************************/ +/****************** E X P O R T E D F U N C T I O N S ******************/ +/****************************************************************************/ + +int as_message_decode(const char* buffer, as_message_t* msg, int length); + +int as_message_encode(char* buffer, as_message_t* msg, int length); + +/* Implemented in the network_api.c body file */ +int as_message_send(as_message_t* as_msg); + +#endif /* __AS_MESSAGE_H__*/ diff --git a/openair3/NAS/COMMON/commonDef.h b/openair3/NAS/COMMON/commonDef.h deleted file mode 120000 index 19553e9b64..0000000000 --- a/openair3/NAS/COMMON/commonDef.h +++ /dev/null @@ -1 +0,0 @@ -../../../openair2/COMMON/commonDef.h \ No newline at end of file diff --git a/openair3/NAS/COMMON/commonDef.h b/openair3/NAS/COMMON/commonDef.h new file mode 100644 index 0000000000..64216b0094 --- /dev/null +++ b/openair3/NAS/COMMON/commonDef.h @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2015, EURECOM (www.eurecom.fr) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the FreeBSD Project. + */ +/* + +Source commonDef.h + +Version 0.1 + +Date 2012/02/27 + +Product NAS stack + +Subsystem include + +Author Frederic Maurel + +Description Contains global common definitions + +*****************************************************************************/ +#ifndef __COMMONDEF_H__ +#define __COMMONDEF_H__ + +#include +#include +#include + +typedef signed char boolean_t; + +#if !defined(TRUE) +#define TRUE (boolean_t)0x01 +#endif + +#if !defined(FALSE) +#define FALSE (boolean_t)0x00 +#endif + +#define BOOL_NOT(b) (b^TRUE) + +#define NAS_UE_ID_FMT "0x%06x" + +/****************************************************************************/ +/********************* G L O B A L C O N S T A N T S *******************/ +/****************************************************************************/ + +#define RETURNok (0) +#define RETURNerror (-1) + +/* + * Name of the environment variable which defines the default directory + * where the NAS application is executed and where are located files + * where non-volatile data are stored + */ +#define DEFAULT_NAS_PATH "PWD" + +/****************************************************************************/ +/************************ G L O B A L T Y P E S ************************/ +/****************************************************************************/ + +/* +----------------------------------------------------------------------------- + Standard data type definitions +----------------------------------------------------------------------------- +*/ +typedef int8_t SByte_t; /* 8 bit signed integer */ +typedef uint8_t Byte_t; /* 8 bit unsigned integer */ + + +/* +----------------------------------------------------------------------------- + Common NAS data type definitions +----------------------------------------------------------------------------- +*/ + +typedef uint8_t Stat_t; /* Registration status */ +typedef uint16_t lac_t; /* Location Area Code */ +typedef uint8_t rac_t; /* Routing Area Code */ +typedef uint16_t tac_t; /* Tracking Area Code */ +typedef uint32_t ci_t; /* Cell Identifier */ +typedef uint8_t AcT_t; /* Access Technology */ + +/* + * International Mobile Subscriber Identity + */ +typedef struct { + Byte_t length; + union { + struct { + Byte_t digit2:4; + Byte_t digit1:4; + Byte_t digit4:4; + Byte_t digit3:4; + Byte_t digit6:4; + Byte_t digit5:4; + Byte_t digit8:4; + Byte_t digit7:4; + Byte_t digit10:4; + Byte_t digit9:4; + Byte_t digit12:4; + Byte_t digit11:4; + Byte_t digit14:4; + Byte_t digit13:4; +#define EVEN_PARITY 0 +#define ODD_PARITY 1 + Byte_t parity:4; + Byte_t digit15:4; + } num; +#define IMSI_SIZE 8 + Byte_t value[IMSI_SIZE]; + } u; +} imsi_t; + +#define NAS_IMSI2STR(iMsI_t_PtR,iMsI_sTr, MaXlEn) \ + {\ + int l_offset = 0;\ + int l_ret = 0;\ + l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u%u%u%u%u",\ + iMsI_t_PtR->u.num.digit1, iMsI_t_PtR->u.num.digit2,\ + iMsI_t_PtR->u.num.digit3, iMsI_t_PtR->u.num.digit4,\ + iMsI_t_PtR->u.num.digit5);\ + if ((iMsI_t_PtR->u.num.digit6 != 0xf) && (l_ret > 0)) {\ + l_offset += l_ret;\ + l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u", iMsI_t_PtR->u.num.digit6);\ + }\ + if (l_ret > 0) {\ + l_offset += l_ret;\ + l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u%u%u%u%u%u%u%u",\ + iMsI_t_PtR->u.num.digit7, iMsI_t_PtR->u.num.digit8,\ + iMsI_t_PtR->u.num.digit9, iMsI_t_PtR->u.num.digit10,\ + iMsI_t_PtR->u.num.digit11, iMsI_t_PtR->u.num.digit12,\ + iMsI_t_PtR->u.num.digit13, iMsI_t_PtR->u.num.digit14);\ + }\ + if ((iMsI_t_PtR->u.num.digit15 != 0xf) && (l_ret > 0)) {\ + l_offset += l_ret;\ + l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u", iMsI_t_PtR->u.num.digit15);\ + }\ + } + +/* + * Mobile subscriber dialing number + */ +typedef struct { + Byte_t ext:1; + /* Type Of Number */ +#define MSISDN_TON_UNKNOWKN 0b000 +#define MSISDN_TON_INTERNATIONAL 0b001 +#define MSISDN_TON_NATIONAL 0b010 +#define MSISDN_TON_NETWORK 0b011 +#define MSISDN_TON_SUBCRIBER 0b100 +#define MSISDN_TON_ABBREVIATED 0b110 +#define MSISDN_TON_RESERVED 0b111 + Byte_t ton:3; + /* Numbering Plan Identification */ +#define MSISDN_NPI_UNKNOWN 0b0000 +#define MSISDN_NPI_ISDN_TELEPHONY 0b0001 +#define MSISDN_NPI_GENERIC 0b0010 +#define MSISDN_NPI_DATA 0b0011 +#define MSISDN_NPI_TELEX 0b0100 +#define MSISDN_NPI_MARITIME_MOBILE 0b0101 +#define MSISDN_NPI_LAND_MOBILE 0b0110 +#define MSISDN_NPI_ISDN_MOBILE 0b0111 +#define MSISDN_NPI_PRIVATE 0b1110 +#define MSISDN_NPI_RESERVED 0b1111 + Byte_t npi:4; + /* Dialing Number */ + struct { + Byte_t lsb:4; + Byte_t msb:4; +#define MSISDN_DIGIT_SIZE 10 + } digit[MSISDN_DIGIT_SIZE]; +} msisdn_t; + +/* + * International Mobile Equipment Identity + */ +typedef imsi_t imei_t; + +/* + * Public Land Mobile Network identifier + * PLMN = BCD encoding (Mobile Country Code + Mobile Network Code) + */ +typedef struct { + Byte_t MCCdigit2:4; + Byte_t MCCdigit1:4; + Byte_t MNCdigit3:4; + Byte_t MCCdigit3:4; + Byte_t MNCdigit2:4; + Byte_t MNCdigit1:4; +} plmn_t; + +/* + * Location Area Identification + */ +typedef struct { + plmn_t plmn; /* + */ + lac_t lac; /* Location Area Code */ +} lai_t; + +/* + * GPRS Routing Area Identification + */ +typedef struct { + plmn_t plmn; /* + */ + lac_t lac; /* Location Area Code */ + rac_t rac; /* Routing Area Code */ +} RAI_t; + +/* + * EPS Tracking Area Identification + */ +typedef struct { + plmn_t plmn; /* + */ + tac_t tac; /* Tracking Area Code */ +} tai_t; + +/* + * EPS Globally Unique MME Identity + */ +typedef struct { + plmn_t plmn; /* + */ + uint16_t MMEgid; /* MME group identifier */ + uint8_t MMEcode; /* MME code */ +} gummei_t; + +/* + * EPS Globally Unique Temporary UE Identity + */ +typedef struct { + gummei_t gummei; /* Globally Unique MME Identity */ + uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */ +} GUTI_t; +#define GUTI2STR(GuTi_PtR, GuTi_StR, MaXlEn) \ + {\ + int l_offset = 0;\ + int l_ret = 0;\ + l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%03u.",\ + GuTi_PtR->gummei.plmn.MCCdigit3 * 100 +\ + GuTi_PtR->gummei.plmn.MCCdigit2 * 10 +\ + GuTi_PtR->gummei.plmn.MCCdigit1);\ + if (l_ret > 0) {\ + l_offset += l_ret;\ + } else {\ + l_offset = MaXlEn;\ + }\ + if (GuTi_PtR->gummei.plmn.MNCdigit1 != 0xf) {\ + l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%03u|%04x|%02x|%08x",\ + GuTi_PtR->gummei.plmn.MNCdigit3 * 100 +\ + GuTi_PtR->gummei.plmn.MNCdigit2 * 10 +\ + GuTi_PtR->gummei.plmn.MNCdigit1,\ + GuTi_PtR->gummei.MMEgid,\ + GuTi_PtR->gummei.MMEcode,\ + GuTi_PtR->m_tmsi);\ + } else {\ + l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%02u|%04x|%02x|%08x",\ + GuTi_PtR->gummei.plmn.MNCdigit2 * 10 +\ + GuTi_PtR->gummei.plmn.MNCdigit1,\ + GuTi_PtR->gummei.MMEgid,\ + GuTi_PtR->gummei.MMEcode,\ + GuTi_PtR->m_tmsi);\ + }\ + } + + + + +/* Checks PLMN validity */ +#define PLMN_IS_VALID(plmn) (((plmn).MCCdigit1 & \ + (plmn).MCCdigit2 & \ + (plmn).MCCdigit3) != 0x0F) + +/* Checks TAC validity */ +#define TAC_IS_VALID(tac) (((tac) != 0x0000) && ((tac) != 0xFFF0)) + +/* Checks TAI validity */ +#define TAI_IS_VALID(tai) (PLMN_IS_VALID((tai).plmn) && \ + TAC_IS_VALID((tai).tac)) +/* + * A list of PLMNs + */ +#define PLMN_LIST_T(SIZE) struct {Byte_t n_plmns; plmn_t plmn[SIZE];} + +/* + * A list of TACs + */ +#define TAC_LIST_T(SIZE) struct {Byte_t n_tacs; TAC_t tac[SIZE];} + +/* + * A list of TAIs + */ +#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];} + +/* + * User notification callback, executed whenever a change of data with + * respect of network information (e.g. network registration and/or + * location change, new PLMN becomes available) is notified by the + * EPS Mobility Management sublayer + */ +typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t, + const char*, size_t); + +typedef enum eps_protocol_discriminator_e { + /* Protocol discriminator identifier for EPS Mobility Management */ + EPS_MOBILITY_MANAGEMENT_MESSAGE = 0x7, + + /* Protocol discriminator identifier for EPS Session Management */ + EPS_SESSION_MANAGEMENT_MESSAGE = 0x2, +} eps_protocol_discriminator_t; + +/****************************************************************************/ +/******************** G L O B A L V A R I A B L E S ********************/ +/****************************************************************************/ + +/****************************************************************************/ +/****************** E X P O R T E D F U N C T I O N S ******************/ +/****************************************************************************/ + +#endif /* __COMMONDEF_H__*/ diff --git a/openair3/NAS/COMMON/networkDef.h b/openair3/NAS/COMMON/networkDef.h deleted file mode 120000 index 2648b55e99..0000000000 --- a/openair3/NAS/COMMON/networkDef.h +++ /dev/null @@ -1 +0,0 @@ -../../../openair2/COMMON/networkDef.h \ No newline at end of file diff --git a/openair3/NAS/COMMON/networkDef.h b/openair3/NAS/COMMON/networkDef.h new file mode 100644 index 0000000000..46716bee24 --- /dev/null +++ b/openair3/NAS/COMMON/networkDef.h @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2015, EURECOM (www.eurecom.fr) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the FreeBSD Project. + */ + +/***************************************************************************** + +Source networkDef.h + +Version 0.1 + +Date 2012/09/21 + +Product NAS stack + +Subsystem include + +Author Frederic Maurel + +Description Contains network's global definitions + +*****************************************************************************/ +#ifndef __NETWORKDEF_H__ +#define __NETWORKDEF_H__ + +/****************************************************************************/ +/********************* G L O B A L C O N S T A N T S *******************/ +/****************************************************************************/ + +/* + * ---------------------- + * Network selection mode + * ---------------------- + */ +#define NET_PLMN_AUTO 0 +#define NET_PLMN_MANUAL 1 + +/* + * --------------------------- + * Network registration status + * --------------------------- + */ +/* not registered, not currently searching an operator to register to */ +#define NET_REG_STATE_OFF 0 +/* registered, home network */ +#define NET_REG_STATE_HN 1 +/* not registered, currently trying to attach or searching an operator + * to register to */ +#define NET_REG_STATE_ON 2 +/* registration denied */ +#define NET_REG_STATE_DENIED 3 +/* unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage) */ +#define NET_REG_STATE_UNKNOWN 4 +/* registered, roaming */ +#define NET_REG_STATE_ROAMING 5 +/* registered for "SMS only", home network */ +#define NET_REG_STATE_SMS_HN 6 +/* registered, for "SMS only", roaming */ +#define NET_REG_STATE_SMS_ROAMING 7 +/* attached for emergency bearer services only (applicable to UTRAN) */ +#define NET_REG_STATE_EMERGENCY 8 + +/* + * ------------------------------------ + * Network access technology indicators + * ------------------------------------ + */ +#define NET_ACCESS_UNAVAILABLE (-1) /* Not available */ +#define NET_ACCESS_GSM 0 /* GSM */ +#define NET_ACCESS_COMPACT 1 /* GSM Compact */ +#define NET_ACCESS_UTRAN 2 /* UTRAN */ +#define NET_ACCESS_EGPRS 3 /* GSM w/EGPRS */ +#define NET_ACCESS_HSDPA 4 /* UTRAN w/HSDPA */ +#define NET_ACCESS_HSUPA 5 /* UTRAN w/HSUPA */ +#define NET_ACCESS_HSDUPA 6 /* UTRAN w/HSDPA and HSUPA */ +#define NET_ACCESS_EUTRAN 7 /* E-UTRAN */ + +/* + * --------------------------------------- + * Network operator representation formats + * --------------------------------------- + */ +#define NET_FORMAT_LONG 0 /* long format alphanumeric */ +#define NET_FORMAT_SHORT 1 /* short format alphanumeric */ +#define NET_FORMAT_NUM 2 /* numeric format */ + +#define NET_FORMAT_MAX_SIZE NET_FORMAT_LONG_SIZE + +/* + * ----------------------------- + * Network operator availability + * ----------------------------- + */ +#define NET_OPER_UNKNOWN 0 /* unknown operator */ +#define NET_OPER_AVAILABLE 1 /* available operator */ +#define NET_OPER_CURRENT 2 /* currently selected operator */ +#define NET_OPER_FORBIDDEN 3 /* forbidden operator */ + +/* + * -------------------------------------- + * Network connection establishment cause + * -------------------------------------- + */ +#define NET_ESTABLISH_CAUSE_EMERGENCY 0x01 +#define NET_ESTABLISH_CAUSE_HIGH_PRIO 0x02 +#define NET_ESTABLISH_CAUSE_MT_ACCESS 0x03 +#define NET_ESTABLISH_CAUSE_MO_SIGNAL 0x04 +#define NET_ESTABLISH_CAUSE_MO_DATA 0x05 +#define NET_ESTABLISH_CAUSE_V1020 0x06 + +/* + * -------------------------------------- + * Network connection establishment type + * -------------------------------------- + */ +#define NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL 0x10 +#define NET_ESTABLISH_TYPE_EMERGENCY_CALLS 0x20 +#define NET_ESTABLISH_TYPE_ORIGINATING_CALLS 0x30 +#define NET_ESTABLISH_TYPE_TERMINATING_CALLS 0x40 +#define NET_ESTABLISH_TYPE_MO_CS_FALLBACK 0x50 + +/* + * ------------------- + * PDN connection type + * ------------------- + */ +#define NET_PDN_TYPE_IPV4 (0 + 1) +#define NET_PDN_TYPE_IPV6 (1 + 1) +#define NET_PDN_TYPE_IPV4V6 (2 + 1) + +/****************************************************************************/ +/************************ G L O B A L T Y P E S ************************/ +/****************************************************************************/ + +/* + * --------------------- + * PDN connection status + * --------------------- + */ +typedef enum { + /* MT = The Mobile Terminal, NW = The Network */ + NET_PDN_MT_DEFAULT_ACT = 1, /* MT has activated a PDN connection */ + NET_PDN_NW_DEFAULT_DEACT, /* NW has deactivated a PDN connection */ + NET_PDN_MT_DEFAULT_DEACT, /* MT has deactivated a PDN connection */ + NET_PDN_NW_DEDICATED_ACT, /* NW has activated an EPS bearer context */ + NET_PDN_MT_DEDICATED_ACT, /* MT has activated an EPS bearer context */ + NET_PDN_NW_DEDICATED_DEACT, /* NW has deactivated an EPS bearer context */ + NET_PDN_MT_DEDICATED_DEACT, /* MT has deactivated an EPS bearer context */ +} network_pdn_state_t; + +/* + * --------------------------- + * Network operator identifier + * --------------------------- + */ +typedef struct { +#define NET_FORMAT_LONG_SIZE 16 /* Long alphanumeric format */ +#define NET_FORMAT_SHORT_SIZE 8 /* Short alphanumeric format */ +#define NET_FORMAT_NUM_SIZE 6 /* Numeric format (PLMN identifier */ + union { + unsigned char alpha_long[NET_FORMAT_LONG_SIZE+1]; + unsigned char alpha_short[NET_FORMAT_SHORT_SIZE+1]; + unsigned char num[NET_FORMAT_NUM_SIZE+1]; + } id; +} network_plmn_t; + +/* + * ------------------------------- + * EPS bearer level QoS parameters + * ------------------------------- + */ +typedef struct { + int gbrUL; /* Guaranteed Bit Rate for uplink */ + int gbrDL; /* Guaranteed Bit Rate for downlink */ + int mbrUL; /* Maximum Bit Rate for uplink */ + int mbrDL; /* Maximum Bit Rate for downlink */ + int qci; /* QoS Class Identifier */ +} network_qos_t; + +/* + * ----------------------------- + * IPv4 packet filter parameters + * ----------------------------- + */ +typedef struct { + unsigned char protocol; /* Protocol identifier */ + unsigned char tos; /* Type of service */ +#define NET_PACKET_FILTER_IPV4_ADDR_SIZE 4 + unsigned char addr[NET_PACKET_FILTER_IPV4_ADDR_SIZE]; + unsigned char mask[NET_PACKET_FILTER_IPV4_ADDR_SIZE]; +} network_ipv4_data_t; + +/* + * ----------------------------- + * IPv6 packet filter parameters + * ----------------------------- + */ +typedef struct { + unsigned char nh; /* Next header type */ + unsigned char tf; /* Traffic class */ +#define NET_PACKET_FILTER_IPV6_ADDR_SIZE 16 + unsigned char addr[NET_PACKET_FILTER_IPV6_ADDR_SIZE]; + unsigned char mask[NET_PACKET_FILTER_IPV6_ADDR_SIZE]; + unsigned int ipsec; /* IPSec security parameter index */ + unsigned int fl; /* Flow label */ +} network_ipv6_data_t; + +/* + * ------------- + * Packet Filter + * ------------- + */ +typedef struct { + unsigned char id; /* Packet filter identifier */ +#define NET_PACKET_FILTER_DOWNLINK 0x01 +#define NET_PACKET_FILTER_UPLINK 0x02 +#define NET_PACKET_FILTER_BIDIR 0x03 + unsigned char dir; /* Packet filter direction */ + unsigned char precedence; /* Evaluation precedence */ + union { + network_ipv4_data_t ipv4; + network_ipv6_data_t ipv6; + } data; + unsigned short lport; /* Local (UE) port number */ + unsigned short rport; /* Remote (network) port number */ +} network_pkf_t; + +/* + * --------------------- + * Traffic Flow Template + * --------------------- + */ +typedef struct { + int n_pkfs; +#define NET_PACKET_FILTER_MAX 16 + network_pkf_t* pkf[NET_PACKET_FILTER_MAX]; +} network_tft_t; + +/* + * User notification callback, executed whenever a change of status with + * respect of PDN connection or EPS bearer context is notified by the EPS + * Session Management sublayer + */ +typedef int (*esm_indication_callback_t) (int, network_pdn_state_t); + +/****************************************************************************/ +/******************** G L O B A L V A R I A B L E S ********************/ +/****************************************************************************/ + +/****************************************************************************/ +/****************** E X P O R T E D F U N C T I O N S ******************/ +/****************************************************************************/ + +#endif /* __NETWORKDEF_H__*/ diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf index 902420ae08..6c309df4db 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf @@ -155,9 +155,9 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth0"; - remote_address = "34:e6:d7:3c:ae:fc"; - local_address = "74:d4:35:cc:8d:15"; + local_if_name = "eth0"; + remote_address = "90:e2:ba:c5:fc:04"; + local_address = "00:13:95:1f:a0:af"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf index 7806e917ac..7f92dff947 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf @@ -159,12 +159,12 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "90:e2:ba:c5:fc:04"; - local_address = "00:13:95:1f:a0:af"; + remote_address = "10.10.10.155"; + local_address = "10.10.10.58"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf index 831010a89a..c8c5b73974 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf @@ -31,15 +31,16 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; tx_gain = 90; - rx_gain = 125; + rx_gain = 120; prach_root = 0; prach_config_index = 0; prach_high_speed = "DISABLE"; @@ -67,9 +68,9 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -90; + pusch_p0_Nominal = -95; pusch_alpha = "AL1"; - pucch_p0_Nominal = -96; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -85,7 +86,7 @@ eNBs = rach_messagePowerOffsetGroupB = ; */ rach_powerRampingStep = 4; - rach_preambleInitialReceivedTargetPower = -108; + rach_preambleInitialReceivedTargetPower = -104; rach_preambleTransMax = 10; rach_raResponseWindowSize = 10; rach_macContentionResolutionTimer = 48; @@ -101,6 +102,8 @@ eNBs = ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } ); @@ -156,8 +159,8 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "34:e6:d7:3c:ae:fc"; - local_address = "74:d4:35:cc:8d:15"; + remote_address = "90:e2:ba:c5:fc:04"; + local_address = "00:13:95:1f:a0:af"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index fd5d38f696..d6b2d4ac82 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -886,6 +886,15 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + // synchronize first reception to frame 0 subframe 0 + if (eNB->iframe_offset == -1) + eNB->iframe_offset = proc->frame_rx; + if (eNB->isubframe_offset == -1) + eNB->isubframe_offset = proc->subframe_rx; + + proc->frame_rx -= eNB->iframe_offset; + proc->subframe_rx -= eNB->isubframe_offset; + proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); // printf("trx_read <- USRP TS %llu (sf %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->first_rx); @@ -1614,6 +1623,9 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->node_timing = node_timing[CC_id]; eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; + eNB->iframe_offset = -1; + eNB->isubframe_offset = -1; + LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); switch (node_function[CC_id]) { From e156079e33dee635b1e2ea2dafe449d52b03b304 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 27 Oct 2016 12:36:38 +0200 Subject: [PATCH 10/59] timeout for UDP recvfrom --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 4 ++++ targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 1bf2f4b2d0..e1fd166800 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -229,7 +229,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t *packet_type = packet_header->sub_type; - printf("CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); + // printf("CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index fc8c175ae9..d507385dd4 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -160,6 +160,7 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam if (bytes_received ==-1) { eth->num_rx_errors++; if (errno == EAGAIN) { + /* again_cnt++; usleep(10); if (again_cnt == 1000) { @@ -169,6 +170,9 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam printf("AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN \n"); goto again; } + */ + printf("Lost IF4p5 connection with %s\n", inet_ntoa(eth->dest_addr.sin_addr)); + exit(-1); } else if (errno == EWOULDBLOCK) { block_cnt++; usleep(10); diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index e770c61935..67ad93f044 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -96,6 +96,7 @@ int trx_eth_start(openair0_device *device) { } else { if(eth_get_dev_conf_udp(device)!=0) return -1; } + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { printf("Setting ETHERNET to RAW_IF5_MODE\n"); if (eth_socket_init_raw(device)!=0) return -1; From 90e3931e4e666467e932abbacffb806b76ffc1c8 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 27 Oct 2016 14:41:58 +0200 Subject: [PATCH 11/59] resynch for timestamp --- openair1/PHY/defs.h | 3 +-- targets/RT/USER/lte-enb.c | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 40444d284f..703bdd2d6f 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -410,8 +410,7 @@ typedef struct PHY_VARS_eNB_s { int single_thread_flag; openair0_rf_map rf_map; int abstraction_flag; - int iframe_offset; - int isubframe_offset; + openair0_timestamp ts_offset; void (*do_prach)(struct PHY_VARS_eNB_s *eNB); void (*fep)(struct PHY_VARS_eNB_s *eNB); int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index a8b5e18556..230a10629e 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -883,29 +883,25 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { fp->nb_antennas_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + + if (proc->first_rx == 1) + eNB->ts_offset = proc->timestamp_rx; + + proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = ((proc->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 - if (eNB->iframe_offset == -1) - eNB->iframe_offset = proc->frame_rx; - if (eNB->isubframe_offset == -1) - eNB->isubframe_offset = proc->subframe_rx; - - proc->frame_rx -= eNB->iframe_offset; - proc->subframe_rx -= eNB->isubframe_offset; proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); - // printf("trx_read <- USRP TS %llu (sf %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->first_rx); + printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx); if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); + LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); + LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->timestamp_rx,proc->frame_rx,*frame); exit_fun("Exiting"); } } else { @@ -1625,8 +1621,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->node_timing = node_timing[CC_id]; eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; - eNB->iframe_offset = -1; - eNB->isubframe_offset = -1; + eNB->ts_offset = 0; LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); switch (node_function[CC_id]) { From bc7df9f5c4637ecb899f683bc22f8e7d45f4407c Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 27 Oct 2016 14:44:08 +0200 Subject: [PATCH 12/59] removed debugging traces --- targets/RT/USER/lte-enb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 230a10629e..fdad1e12c1 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -892,7 +892,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // synchronize first reception to frame 0 subframe 0 proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); - printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx); + //printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx); if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ From afbab21a54ddcc90be83297b6e29def2476f6f24 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 18 Nov 2016 13:40:14 -0800 Subject: [PATCH 13/59] put MAX_NUM_CCs back to 1 --- cmake_targets/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c1507de61b..5e86d59378 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") -add_integer_option(MAX_NUM_CCs 2 "????") +add_integer_option(MAX_NUM_CCs 1 "????") add_boolean_option(MU_RECEIVER False "????") add_boolean_option(NEW_FFT True "????") add_boolean_option(OPENAIR1 True "????") From f974ec264e8e1469d796c8d58161c5d09959686e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 21 Nov 2016 10:37:01 +0800 Subject: [PATCH 14/59] debugging information in lte-enb, addition of external reference option in lte-softmodem and usrp_lib.cpp --- cmake_targets/CMakeLists.txt | 2 +- targets/ARCH/COMMON/common_lib.h | 10 ++++++++ targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 11 ++++++++- targets/RT/USER/lte-enb.c | 25 +++++++++++--------- targets/RT/USER/lte-softmodem.c | 13 ++++++++-- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c1507de61b..5e86d59378 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") -add_integer_option(MAX_NUM_CCs 2 "????") +add_integer_option(MAX_NUM_CCs 1 "????") add_boolean_option(MU_RECEIVER False "????") add_boolean_option(NEW_FFT True "????") add_boolean_option(OPENAIR1 True "????") diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 99350a4c1e..0011842a03 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -134,6 +134,14 @@ typedef struct { double offset; } rx_gain_calib_table_t; +/*! \brief Clock source types */ +typedef enum { + //! This tells the underlying hardware to use the internal reference + internal=0, + //! This tells the underlying hardware to use the external reference + external=1 +} clock_source_t; + /*! \brief RF frontend parameters set by application */ typedef struct { //! Module ID for this configuration @@ -186,6 +194,8 @@ typedef struct { double rx_bw; //! TX bandwidth in Hz double tx_bw; + //! clock source + clock_source_t clock_source; //! Auto calibration flag int autocal[4]; //! rf devices work with x bits iqs when oai have its own iq format diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 1cbabf5dcc..106fb369db 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -587,7 +587,10 @@ extern "C" { // s->usrp->set_tx_subdev_spec(tx_subdev); // lock mboard clocks - s->usrp->set_clock_source("internal"); + if (openair0_cfg[0].clock_source == internal) + s->usrp->set_clock_source("internal"); + else + s->usrp->set_clock_source("external"); //Setting device type to USRP X300/X310 device->type=USRP_X300_DEV; @@ -643,6 +646,12 @@ extern "C" { // s->usrp->set_clock_source("internal"); // set master clock rate and sample rate for tx & rx for streaming + // lock mboard clocks + if (openair0_cfg[0].clock_source == internal) + s->usrp->set_clock_source("internal"); + else + s->usrp->set_clock_source("external"); + device->type = USRP_B200_DEV; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index fdad1e12c1..8999a717ce 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -654,11 +654,11 @@ void fh_if5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } else { if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); + LOG_E(PHY,"fh_if5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->frame_rx,*frame); + LOG_E(PHY,"fh_if5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->frame_rx,*frame); exit_fun("Exiting"); } } @@ -688,11 +688,11 @@ void fh_if4p5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } else { if (proc->frame_rx != *frame) { - LOG_E(PHY,"frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); + LOG_E(PHY,"fh_if4p5_asynch_UL: frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); exit_fun("Exiting"); } if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); + LOG_E(PHY,"fh_if4p5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); exit_fun("Exiting"); } } @@ -728,11 +728,11 @@ void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } else { if (subframe_tx != *subframe) { - LOG_E(PHY,"subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); + LOG_E(PHY,"fh_if5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); exit_fun("Exiting"); } if (frame_tx != *frame) { - LOG_E(PHY,"frame_tx %d is not what we expect %d\n",frame_tx,*frame); + LOG_E(PHY,"fh_if5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); exit_fun("Exiting"); } } @@ -760,11 +760,11 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } else { if (frame_tx != *frame) { - LOG_E(PHY,"frame_tx %d is not what we expect %d\n",frame_tx,*frame); + LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); exit_fun("Exiting"); } if (subframe_tx != *subframe) { - LOG_E(PHY,"subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); + LOG_E(PHY,"fh_if4p5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); exit_fun("Exiting"); } } @@ -882,6 +882,9 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { fp->samples_per_tti, fp->nb_antennas_rx); + if (rxs != fp->samples_per_tti) + printf("Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); if (proc->first_rx == 1) @@ -892,16 +895,16 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // synchronize first reception to frame 0 subframe 0 proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); - //printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx); + // printf("trx_read <- USRP TS %lu (offset %d sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,eNB->ts_offset,proc->subframe_rx,proc->frame_rx,proc->first_rx); if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); + LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->timestamp_rx,proc->frame_rx,*frame); + LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->timestamp_rx,proc->frame_rx,*frame); exit_fun("Exiting"); } } else { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index d2ba49dcac..eeb06753f3 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -168,6 +168,7 @@ volatile int oai_exit = 0; +static clock_source_t clock_source = internal; static char UE_flag=0; unsigned int mmapped_dma=0; @@ -386,6 +387,7 @@ void help (void) { printf(" --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n"); printf(" --mmapped-dma sets flag for improved EXMIMO UE performance\n"); printf(" --single-thread runs lte-softmodem in only one thread\n"); + printf(" --external-clock tells hardware to use an external clock reference\n"); printf(" -C Set the downlink frequency for all component carriers\n"); printf(" -d Enable soft scope and L1 and L2 stats (Xforms)\n"); printf(" -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"); @@ -657,7 +659,7 @@ void *l2l1_task(void *arg) #endif - + static void get_options (int argc, char **argv) { @@ -693,6 +695,7 @@ static void get_options (int argc, char **argv) LONG_OPTION_PHYTEST, LONG_OPTION_MMAPPED_DMA, LONG_OPTION_SINGLE_THREAD, + LONG_OPTION_EXTERNAL_CLOCK, #if T_TRACER LONG_OPTION_T_PORT, LONG_OPTION_T_NOWAIT, @@ -718,6 +721,7 @@ static void get_options (int argc, char **argv) {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST}, {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA}, {"single-thread", no_argument, NULL, LONG_OPTION_SINGLE_THREAD}, + {"external-clock", no_argument, NULL, LONG_OPTION_EXTERNAL_CLOCK}, #if T_TRACER {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, {"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT}, @@ -818,7 +822,11 @@ static void get_options (int argc, char **argv) case LONG_OPTION_SINGLE_THREAD: single_thread_flag = 1; break; - + + case LONG_OPTION_EXTERNAL_CLOCK: + clock_source = external; + break; + #if T_TRACER case LONG_OPTION_T_PORT: { extern int T_port; @@ -1325,6 +1333,7 @@ void init_openair0() { openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; + openair0_cfg[card].clock_source = clock_source; openair0_cfg[card].tx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx)); openair0_cfg[card].rx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx)); From 958c66c6db20a7087fdff1627f107afe63549974 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 21 Nov 2016 12:06:22 +0800 Subject: [PATCH 15/59] handling of timing drift in rfdevice --- targets/RT/USER/lte-enb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8999a717ce..74e75bdc4d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -843,6 +843,8 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { unsigned int rxs,txs; int i; int tx_sfoffset = 3;//(eNB->single_thread_flag == 1) ? 3 : 3; + openair0_timestamp old_ts; + if (proc->first_rx==0) { // Transmit TX buffer based on timestamp from RX @@ -876,6 +878,8 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); + old_ts = proc->timestamp_rx; + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, &(proc->timestamp_rx), rxp, @@ -883,13 +887,18 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { fp->nb_antennas_rx); if (rxs != fp->samples_per_tti) - printf("Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); + LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); if (proc->first_rx == 1) eNB->ts_offset = proc->timestamp_rx; - + else { + if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { + LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts); + eNB->ts_offset += (proc->timestamp_rx - old_ts); + } + } proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; proc->subframe_rx = ((proc->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 From e0314d8b755ce1fc8007db37efce9459ab336348 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 21 Nov 2016 12:19:21 +0800 Subject: [PATCH 16/59] update to timing drift compensation in rfdevice --- targets/RT/USER/lte-enb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 74e75bdc4d..58494caed4 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -895,8 +895,8 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { eNB->ts_offset = proc->timestamp_rx; else { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { - LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts); - eNB->ts_offset += (proc->timestamp_rx - old_ts); + LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts - fp->samples_per_tti); + eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); } } proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; From 20b0aae98ba0aaedfd035a287437b2079765b8c5 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 21 Nov 2016 18:00:36 +0800 Subject: [PATCH 17/59] integration of over-the-air synchronization mechanism for distributed RRU --- openair1/PHY/LTE_ESTIMATION/lte_sync_time.c | 21 +-- openair1/PHY/defs.h | 16 ++ targets/RT/USER/lte-enb.c | 193 +++++++++++++++++++- targets/RT/USER/lte-softmodem.c | 12 +- 4 files changed, 225 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index dfb39a510f..5f0ba9b2d2 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -517,14 +517,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain // perform a time domain correlation using the oversampled sync sequence - unsigned int n, ar, peak_val, peak_pos, mean_val; + unsigned int n, ar, peak_val, peak_pos; + uint64_t mean_val; int result; short *primary_synch_time; int eNB_id = frame_parms->Nid_cell%3; // msg("[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length); if (sync_corr_eNB == NULL) { - msg("[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n"); + LOG_E(PHY,"[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n"); return(-1); } @@ -542,7 +543,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain break; default: - msg("[SYNC TIME] Illegal eNB_id!\n"); + LOG_E(PHY,"[SYNC TIME] Illegal eNB_id!\n"); return (-1); } @@ -574,7 +575,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain peak_val); } */ - mean_val += (sync_corr_eNB[n]>>10); + mean_val += sync_corr_eNB[n]; if (sync_corr_eNB[n]>peak_val) { peak_val = sync_corr_eNB[n]; @@ -582,17 +583,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain } } + mean_val/=length; + *peak_val_out = peak_val; - if (peak_val <= (40*mean_val)) { -#ifdef DEBUG_PHY - msg("[SYNC TIME] No peak found (%u,%u,%u,%u)\n",peak_pos,peak_val,mean_val,40*mean_val); -#endif + if (peak_val <= (40*(uint32_t)mean_val)) { + LOG_D(PHY,"[SYNC TIME] No peak found (%u,%u,%u,%u)\n",peak_pos,peak_val,mean_val,40*mean_val); return(-1); } else { -#ifdef DEBUG_PHY - msg("[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %u\n",peak_pos,peak_val,mean_val); -#endif + LOG_D(PHY,"[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %u\n",peak_pos,peak_val,mean_val); return(peak_pos); } diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 703bdd2d6f..e42157769d 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -256,6 +256,8 @@ typedef struct eNB_proc_t_s { /// \brief Instance count for rx processing thread. /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; + // instance count for over-the-air eNB synchronization + int instance_cnt_synch; /// \internal This variable is protected by \ref mutex_asynch_rxtx. int instance_cnt_asynch_rxtx; /// pthread structure for FH processing thread @@ -280,6 +282,8 @@ typedef struct eNB_proc_t_s { pthread_attr_t attr_single; /// pthread attributes for prach processing thread pthread_attr_t attr_prach; + /// pthread attributes for over-the-air synch thread + pthread_attr_t attr_synch; /// pthread attributes for asynchronous RX thread pthread_attr_t attr_asynch_rxtx; /// scheduling parameters for parallel fep thread @@ -294,6 +298,8 @@ typedef struct eNB_proc_t_s { struct sched_param sched_param_single; /// scheduling parameters for prach thread struct sched_param sched_param_prach; + /// scheduling parameters for over-the-air synchronization thread + struct sched_param sched_param_synch; /// scheduling parameters for asynch_rxtx thread struct sched_param sched_param_asynch_rxtx; /// pthread structure for parallel fep thread @@ -304,6 +310,8 @@ typedef struct eNB_proc_t_s { pthread_t pthread_te; /// pthread structure for PRACH thread pthread_t pthread_prach; + /// pthread structure for eNB synch thread + pthread_t pthread_synch; /// condition variable for parallel fep thread pthread_cond_t cond_fep; /// condition variable for parallel turbo-decoder thread @@ -314,6 +322,8 @@ typedef struct eNB_proc_t_s { pthread_cond_t cond_FH; /// condition variable for PRACH processing thread; pthread_cond_t cond_prach; + // condition variable for over-the-air eNB synchronization + pthread_cond_t cond_synch; /// condition variable for asynch RX/TX thread pthread_cond_t cond_asynch_rxtx; /// mutex for parallel fep thread @@ -326,6 +336,8 @@ typedef struct eNB_proc_t_s { pthread_mutex_t mutex_FH; /// mutex for PRACH thread pthread_mutex_t mutex_prach; + // mutex for over-the-air eNB synchronization + pthread_mutex_t mutex_synch; /// mutex for asynch RX/TX thread pthread_mutex_t mutex_asynch_rxtx; /// parameters for turbo-decoding worker thread @@ -411,6 +423,10 @@ typedef struct PHY_VARS_eNB_s { openair0_rf_map rf_map; int abstraction_flag; openair0_timestamp ts_offset; + // indicator for synchronization state of eNB + int in_synch; + // indicator for master/slave (RRU) + int is_slave; void (*do_prach)(struct PHY_VARS_eNB_s *eNB); void (*fep)(struct PHY_VARS_eNB_s *eNB); int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 58494caed4..66d60bf2cc 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -161,7 +161,7 @@ static struct { void exit_fun(const char* s); -void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int); +void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int,int); void stop_eNB(int nb_inst); @@ -1122,6 +1122,114 @@ void wakeup_slaves(eNB_proc_t *proc) { } } +uint32_t sync_corr[307200] __attribute__((aligned(32))); + +// This thread run the initial synchronization like a UE +void *eNB_thread_synch(void *arg) { + + PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)arg; + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + int32_t sync_pos,sync_pos2; + uint32_t peak_val; + + thread_top_init("eNB_thread_synch",0,5000000,10000000,10000000); + + wait_sync("eNB_thread_synch"); + + // initialize variables for PSS detection + lte_sync_time_init(&eNB->frame_parms); + + while (!oai_exit) { + + // wait to be woken up + pthread_mutex_lock(&eNB->proc.mutex_synch); + while (eNB->proc.instance_cnt_synch < 0) + pthread_cond_wait(&eNB->proc.cond_synch,&eNB->proc.mutex_synch); + pthread_mutex_unlock(&eNB->proc.mutex_synch); + + // if we're not in synch, then run initial synch + if (eNB->in_synch == 0) { + // run intial synch like UE + LOG_I(PHY,"Running initial synchronization\n"); + + sync_pos = lte_sync_time_eNB(eNB->common_vars.rxdata[0], + fp, + fp->samples_per_tti*5, + &peak_val, + sync_corr); + LOG_I(PHY,"eNB synch: %d, val %d\n",sync_pos,peak_val); + + if (sync_pos >= 0) { + if (sync_pos >= fp->nb_prefix_samples) + sync_pos2 = sync_pos - fp->nb_prefix_samples; + else + sync_pos2 = sync_pos + (fp->samples_per_tti*10) - fp->nb_prefix_samples; + + if (fp->frame_type == FDD) { + + // PSS is hypothesized in last symbol of first slot in Frame + int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; + + if (sync_pos2 >= sync_pos_slot) + eNB->rx_offset = sync_pos2 - sync_pos_slot; + else + eNB->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; + } + else { + + } + + LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,eNB->rx_offset); + + + /* if ((peak_val > 10000) && (sync_pos == -1)) { + // if (sync_pos++ > 3) { + write_output("eNB_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); + write_output("eNB_rx.m","rxs",(void*)eNB->common_vars.rxdata[0][0],fp->samples_per_tti*10,1,1); + exit(-1); + }*/ + } + } + + // release thread + pthread_mutex_lock(&eNB->proc.mutex_synch); + eNB->proc.instance_cnt_synch--; + pthread_mutex_unlock(&eNB->proc.mutex_synch); + } // oai_exit + + lte_sync_time_free(); + +} + +int wakeup_synch(PHY_VARS_eNB *eNB){ + + struct timespec wait; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + // wake up synch thread + // lock the synch mutex and make sure the thread is ready + if (pthread_mutex_timedlock(&eNB->proc.mutex_synch,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB synch thread (IC %d)\n", eNB->proc.instance_cnt_synch ); + exit_fun( "error locking mutex_synch" ); + return(-1); + } + + ++eNB->proc.instance_cnt_synch; + + // the thread can now be woken up + if (pthread_cond_signal(&eNB->proc.cond_synch) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB synch thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &eNB->proc.mutex_synch ); + + return(0); +} + /*! * \brief The Fronthaul thread of RRU/RAU/RCC/eNB * In the case of RRU/eNB, handles interface with external RF @@ -1242,6 +1350,8 @@ static void* eNB_thread_prach( void* param ) { return &eNB_thread_prach_status; } + + static void* eNB_thread_single( void* param ) { static int eNB_thread_single_status; @@ -1249,9 +1359,24 @@ static void* eNB_thread_single( void* param ) { eNB_proc_t *proc = (eNB_proc_t*)param; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + + void *rxp[2],*rxp2[2]; int subframe=0, frame=0; + int32_t dummy_rx[fp->nb_antennas_rx][fp->samples_per_tti] __attribute__((aligned(32))); + + int ic; + + int rxs; + + int i; + + // initialize the synchronization buffer to the common_vars.rxdata + for (int i=0;inb_antennas_rx;i++) + rxp[i] = &eNB->common_vars.rxdata[0][i][0]; + // set default return value eNB_thread_single_status = 0; @@ -1280,6 +1405,57 @@ static void* eNB_thread_single( void* param ) { pthread_mutex_unlock(&proc->mutex_asynch_rxtx); pthread_cond_signal(&proc->cond_asynch_rxtx); + + + // if this is a slave eNB, try to synchronize on the DL frequency + if ((eNB->is_slave) && + ((eNB->node_function >= NGFI_RRU_IF5))) { + // if FDD, switch RX on DL frequency + + double temp_freq1 = eNB->rfdevice.openair0_cfg->rx_freq[0]; + double temp_freq2 = eNB->rfdevice.openair0_cfg->tx_freq[0]; + for (i=0;i<4;i++) { + eNB->rfdevice.openair0_cfg->rx_freq[i] = eNB->rfdevice.openair0_cfg->tx_freq[i]; + eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq1; + } + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); + + while ((eNB->in_synch ==0)&&(!oai_exit)) { + // read in frame + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp, + fp->samples_per_tti*10, + fp->nb_antennas_rx); + // wakeup synchronization processing thread + wakeup_synch(eNB); + ic=0; + + while ((ic>=0)&&(!oai_exit)) { + // continuously read in frames, 1ms at a time, + // until we are done with the synchronization procedure + + for (i=0; inb_antennas_rx; i++) + rxp2[i] = (void*)&dummy_rx[i][0]; + for (i=0;i<10;i++) + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp2, + fp->samples_per_tti, + fp->nb_antennas_rx); + pthread_mutex_lock(&eNB->proc.mutex_synch); + ic = eNB->proc.instance_cnt_synch; + pthread_mutex_unlock(&eNB->proc.mutex_synch); + } // ic>=0 + } // in_synch==0 + for (i=0;i<4;i++) { + eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; + eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq2; + } + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); + } // if RRU and slave + + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { @@ -1334,7 +1510,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te=NULL,*attr_synch=NULL; for (CC_id=0; CC_idinstance_cnt_FH = -1; proc->instance_cnt_asynch_rxtx = -1; proc->CC_id = CC_id; - + proc->instance_cnt_synch = -1; + proc->first_rx=1; proc->first_tx=1; @@ -1359,13 +1536,16 @@ void init_eNB_proc(int inst) { pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); + pthread_mutex_init( &proc->mutex_synch,NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); + pthread_cond_init( &proc->cond_synch,NULL); pthread_attr_init( &proc->attr_FH); pthread_attr_init( &proc->attr_prach); + pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_single); pthread_attr_init( &proc->attr_fep); @@ -1378,6 +1558,7 @@ void init_eNB_proc(int inst) { attr1 = &proc_rxtx[1].attr_rxtx; attr_FH = &proc->attr_FH; attr_prach = &proc->attr_prach; + attr_synch = &proc->attr_synch; attr_asynch = &proc->attr_asynch_rxtx; attr_single = &proc->attr_single; attr_fep = &proc->attr_fep; @@ -1397,6 +1578,7 @@ void init_eNB_proc(int inst) { init_te_thread(eNB,attr_te); } pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc ); + pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB); if ((eNB->node_timing == synch_to_other) || (eNB->node_function == NGFI_RRU_IF5) || (eNB->node_function == NGFI_RRU_IF4p5)) @@ -1619,7 +1801,7 @@ extern void eNB_fep_full(PHY_VARS_eNB *eNB); extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB); extern void do_prach(PHY_VARS_eNB *eNB); -void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *eth_params,int single_thread_flag) { +void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *eth_params,int single_thread_flag,int wait_for_sync) { int CC_id; int inst; @@ -1634,6 +1816,9 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; eNB->ts_offset = 0; + eNB->in_synch = 0; + eNB->is_slave = (wait_for_sync>0) ? 1 : 0; + LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); switch (node_function[CC_id]) { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index eeb06753f3..d2f2f9ccfb 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -120,7 +120,7 @@ extern int netlink_init(void); // In lte-enb.c extern int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg); -extern void init_eNB(eNB_func_t *, eNB_timing_t *,int,eth_params_t *,int); +extern void init_eNB(eNB_func_t *, eNB_timing_t *,int,eth_params_t *,int,int); extern void stop_eNB(int); extern void kill_eNB_proc(void); @@ -170,6 +170,8 @@ volatile int oai_exit = 0; static clock_source_t clock_source = internal; +static wait_for_sync = 0; + static char UE_flag=0; unsigned int mmapped_dma=0; int single_thread_flag=0; @@ -696,6 +698,7 @@ static void get_options (int argc, char **argv) LONG_OPTION_MMAPPED_DMA, LONG_OPTION_SINGLE_THREAD, LONG_OPTION_EXTERNAL_CLOCK, + LONG_OPTION_WAIT_FOR_SYNC, #if T_TRACER LONG_OPTION_T_PORT, LONG_OPTION_T_NOWAIT, @@ -722,6 +725,7 @@ static void get_options (int argc, char **argv) {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA}, {"single-thread", no_argument, NULL, LONG_OPTION_SINGLE_THREAD}, {"external-clock", no_argument, NULL, LONG_OPTION_EXTERNAL_CLOCK}, + {"wait-for-sync", no_argument, NULL, LONG_OPTION_WAIT_FOR_SYNC}, #if T_TRACER {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, {"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT}, @@ -827,6 +831,10 @@ static void get_options (int argc, char **argv) clock_source = external; break; + case LONG_OPTION_WAIT_FOR_SYNC: + wait_for_sync = 1; + break; + #if T_TRACER case LONG_OPTION_T_PORT: { extern int T_port; @@ -1808,7 +1816,7 @@ int main( int argc, char **argv ) // start the main thread if (UE_flag == 1) init_UE(1); else { - init_eNB(node_function,node_timing,1,eth_params,single_thread_flag); + init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync); // Sleep to allow all threads to setup number_of_cards = 1; From 1fcc78375cadbe7a302178bcfee86bc327388d6f Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 21 Nov 2016 18:02:10 +0800 Subject: [PATCH 18/59] debugging traces in lte-enb --- cmake_targets/CMakeLists.txt | 2 +- targets/RT/USER/lte-enb.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5e86d59378..c1507de61b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") -add_integer_option(MAX_NUM_CCs 1 "????") +add_integer_option(MAX_NUM_CCs 2 "????") add_boolean_option(MU_RECEIVER False "????") add_boolean_option(NEW_FFT True "????") add_boolean_option(OPENAIR1 True "????") diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8999a717ce..d3da134ee8 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -936,12 +936,12 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,subframe); + LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,subframe); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,frame); + LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,frame); exit_fun("Exiting"); } } else { @@ -989,11 +989,11 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id); + LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id); exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); + LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); exit_fun("Exiting"); } } else { From 09a2fa65e3e83802bbe332d89b010f73252f72a0 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 22 Nov 2016 16:09:43 +0800 Subject: [PATCH 19/59] further additions for multiple-RRU synchronizationwq --- targets/RT/USER/lte-enb.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 66d60bf2cc..5024154f40 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -761,11 +761,13 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { else { if (frame_tx != *frame) { LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - exit_fun("Exiting"); + *frame = frame_tx; + // exit_fun("Exiting"); } if (subframe_tx != *subframe) { LOG_E(PHY,"fh_if4p5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - exit_fun("Exiting"); + *subframe = subframe_tx; + // exit_fun("Exiting"); } } if (packet_type == IF4p5_PDLFFT) { @@ -1181,13 +1183,15 @@ void *eNB_thread_synch(void *arg) { LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,eNB->rx_offset); - - /* if ((peak_val > 10000) && (sync_pos == -1)) { + /* + if ((peak_val > 300000) && (sync_pos > 0)) { // if (sync_pos++ > 3) { write_output("eNB_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); write_output("eNB_rx.m","rxs",(void*)eNB->common_vars.rxdata[0][0],fp->samples_per_tti*10,1,1); exit(-1); - }*/ + } + */ + eNB->in_synch=1; } } @@ -1448,9 +1452,16 @@ static void* eNB_thread_single( void* param ) { pthread_mutex_unlock(&eNB->proc.mutex_synch); } // ic>=0 } // in_synch==0 + // read in rx_offset samples + LOG_I(PHY,"Resynchronizing by %d samples\n",eNB->rx_offset); + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp, + eNB->rx_offset, + fp->nb_antennas_rx); for (i=0;i<4;i++) { eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; - eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq2; + eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; } eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); } // if RRU and slave From 63c68100f30271d9e9180b8443d473557b9f58fe Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 10:15:39 +0800 Subject: [PATCH 20/59] spawn a thread for frequency adjustments in USRP device driver --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 106fb369db..baa4ff1642 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -360,7 +360,15 @@ static bool is_equal(double a, double b) return std::fabs(a-b) < std::numeric_limits::epsilon(); } -/*! \brief Set frequencies (TX/RX) +void *freq_thread(void *arg) { + + openair0_device *device=(openair0_device *)arg; + usrp_state_t *s = (usrp_state_t*)device->priv; + + s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); + s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); +} +/*! \brief Set frequencies (TX/RX). Spawns a thread to handle the frequency change to not block the calling thread * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application * \param dummy dummy variable not used @@ -369,10 +377,12 @@ static bool is_equal(double a, double b) int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg, int dummy) { usrp_state_t *s = (usrp_state_t*)device->priv; + pthread_t f_thread; printf("Setting USRP TX Freq %f, RX Freq %f\n",openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0]); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[0]); + + // spawn a thread to handle the frequency change to not block the calling thread + pthread_create(&f_thread,NULL,freq_thread,(void*)device); return(0); From f02c1f20e43ac6591c040a355a838ca9cefcacc0 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 13:42:37 +0800 Subject: [PATCH 21/59] frame synchronization mechanism and robustification of if4p5 packet handling for out-of-order asynchronous reception (PDLFFT) --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- openair1/PHY/defs.h | 2 ++ targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 23 ++++++++++++++++---- targets/RT/USER/lte-enb.c | 22 +++++++++++-------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index e1fd166800..1aff7d876b 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -229,7 +229,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t *packet_type = packet_header->sub_type; - // printf("CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); + // LOG_I(PHY,"CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index e42157769d..9ba1c53d64 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -238,6 +238,8 @@ typedef struct eNB_proc_t_s { openair0_timestamp timestamp_tx; /// subframe to act upon for reception int subframe_rx; + /// symbol mask for IF4p5 reception per subframe + uint32_t symbol_mask[10]; /// subframe to act upon for PRACH int subframe_prach; /// frame to act upon for reception diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 106fb369db..0fed5cc9de 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -360,19 +360,34 @@ static bool is_equal(double a, double b) return std::fabs(a-b) < std::numeric_limits::epsilon(); } -/*! \brief Set frequencies (TX/RX) +void *freq_thread(void *arg) { + + openair0_device *device=(openair0_device *)arg; + usrp_state_t *s = (usrp_state_t*)device->priv; + + s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); + s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); +} +/*! \brief Set frequencies (TX/RX). Spawns a thread to handle the frequency change to not block the calling thread * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application * \param dummy dummy variable not used * \returns 0 in success */ -int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg, int dummy) { +int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg, int dont_block) { usrp_state_t *s = (usrp_state_t*)device->priv; + pthread_t f_thread; printf("Setting USRP TX Freq %f, RX Freq %f\n",openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0]); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[0]); + + // spawn a thread to handle the frequency change to not block the calling thread + if (dont_block == 1) + pthread_create(&f_thread,NULL,freq_thread,(void*)device); + else { + s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); + s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + } return(0); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5024154f40..49b9bd4d0c 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -744,11 +744,10 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { eNB_proc_t *proc = &eNB->proc; uint16_t packet_type; - uint32_t symbol_number,symbol_mask,symbol_mask_full; + uint32_t symbol_number,symbol_mask_full; int subframe_tx,frame_tx; symbol_number = 0; - symbol_mask = 0; symbol_mask_full = (1<symbols_per_tti)-1; do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! @@ -765,21 +764,24 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // exit_fun("Exiting"); } if (subframe_tx != *subframe) { - LOG_E(PHY,"fh_if4p5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - *subframe = subframe_tx; - // exit_fun("Exiting"); + LOG_E(PHY,"fh_if4p5_asynch_DL: (frame %d) subframe_tx %d is not what we expect %d\n",frame_tx,subframe_tx,*subframe); + //*subframe = subframe_tx; + //exit_fun("Exiting"); } } if (packet_type == IF4p5_PDLFFT) { - symbol_mask = symbol_mask | (1<symbol_mask[subframe_tx] =proc->symbol_mask[subframe_tx] | (1<symbol_mask[*subframe] != symbol_mask_full); + + // intialize this to zero after we're done with the subframe + proc->symbol_mask[*subframe] = 0; - do_OFDM_mod_rt(subframe_tx, eNB); + do_OFDM_mod_rt(*subframe, eNB); } /*! @@ -1463,7 +1465,7 @@ static void* eNB_thread_single( void* param ) { eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; } - eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,1); } // if RRU and slave @@ -1540,6 +1542,8 @@ void init_eNB_proc(int inst) { proc->first_rx=1; proc->first_tx=1; + for (i=0;i<10;i++) proc->symbol_mask[i]=0; + pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); From 3e838ca675bb2789185b7fc568d9cc9203331800 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 13:46:47 +0800 Subject: [PATCH 22/59] temporary commit for testing 2 RRU case as TM2 (distributed antennas) --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 16 +++++++------ openair1/PHY/defs.h | 2 ++ openair1/SCHED/phy_procedures_lte_eNb.c | 6 ++--- targets/RT/USER/lte-enb.c | 30 +++++++++++++++++++------ 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index e1fd166800..1e2e59056c 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -40,6 +40,7 @@ #include "PHY/defs.h" #include "PHY/TOOLS/alaw_lut.h" +#include "PHY/extern.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" @@ -47,7 +48,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type, int k) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - int32_t **txdataF = eNB->common_vars.txdataF[0]; + int32_t **txdataF = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0]; int32_t **rxdataF = eNB->common_vars.rxdataF[0]; int16_t **rxsigF = eNB->prach_vars.rxsigF; void *tx_buffer = eNB->ifbuffer.tx; @@ -61,7 +62,8 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type 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 (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); if (packet_type == IF4p5_PDLFFT) { db_fulllength = 12*fp->N_RB_DL; @@ -81,10 +83,10 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { for (element_id=0; element_idCC_id][blockoffsetF+element_id]; data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8); - i = (uint16_t*) &txdataF[0][slotoffsetF+element_id]; + i = (uint16_t*) &txdataF[eNB->CC_id][slotoffsetF+element_id]; data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8); } @@ -177,7 +179,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type AssertFatal(1==0, "send_IF4p5 - Unknown packet_type %x", packet_type); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 ); + if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 ); return; } @@ -194,7 +196,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t 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 ); + if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 ); if (eNB->node_function == NGFI_RRU_IF4p5) { db_fulllength = (12*fp->N_RB_DL); @@ -281,7 +283,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 ); + if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 ); return; } diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index e42157769d..90c26431c9 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -242,6 +242,8 @@ typedef struct eNB_proc_t_s { int subframe_prach; /// frame to act upon for reception int frame_rx; + /// frame offset for secondary eNBs (to correct for frame asynchronism at startup) + int frame_offset; /// frame to act upon for PRACH int frame_prach; /// \internal This variable is protected by \ref mutex_fep. diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 5603ac8421..0ee6c1ff11 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1103,7 +1103,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; DCI_ALLOC_t *dci_alloc=(DCI_ALLOC_t *)NULL; - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; #if defined(SMBV) // counts number of allocations in subframe @@ -2741,7 +2741,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB){ LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1); + int offset = eNB->CC_id;//(eNB->single_thread_flag==1) ? 0 : (subframe&1); if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; @@ -2775,7 +2775,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - int offset = (proc == &eNB->proc.proc_rxtx[0]) ? 0 : 1; + int offset = eNB->CC_id;//(proc == &eNB->proc.proc_rxtx[0]) ? 0 : 1; if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index b2f286dfcf..823e1322ce 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -419,7 +419,7 @@ void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { } void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - send_IF4p5(eNB,proc->frame_tx, proc->subframe_tx, IF4p5_PDLFFT, 0); + send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); } void proc_tx_high0(PHY_VARS_eNB *eNB, @@ -427,7 +427,7 @@ void proc_tx_high0(PHY_VARS_eNB *eNB, relaying_type_t r_type, PHY_VARS_RN *rn) { - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); @@ -604,7 +604,8 @@ static void* eNB_thread_rxtx( void* param ) { if (oai_exit) break; - if (rxtx(eNB,proc,thread_name) < 0) break; + if (eNB->CC_id==0) + if (rxtx(eNB,proc,thread_name) < 0) break; } // while !oai_exit @@ -854,7 +855,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // prepare tx buffer pointers for (i=0; inb_antennas_tx; i++) - txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; + txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, @@ -981,6 +982,7 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); + proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; if (packet_type == IF4p5_PULFFT) { symbol_mask = symbol_mask | (1<first_rx == 0) { if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id); + LOG_E(PHY,"rx_fh_if4p5, CC_id %d: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",eNB->CC_id,proc->subframe_rx,*subframe,eNB->CC_id); + /* + if (proc->subframe_rx> *subframe) { + LOG_E(PHY,"rx_fh_if4p5, CC_id %d: this is ahead of time, so adjusting\n",eNB->CC_id); + *subframe = proc->subframe_rx; + } + else { + LOG_E(PHY,"rx_fh_ip4p5, CC_id %d: this is behind time, dropping\n"); + }*/ exit_fun("Exiting"); } if (proc->frame_rx != *frame) { @@ -1007,7 +1017,12 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } } else { proc->first_rx = 0; - *frame = proc->frame_rx; + if (eNB->CC_id==0) + proc->frame_offset = 0; + else + proc->frame_offset = PHY_vars_eNB_g[0][0]->proc.frame_rx; + + *frame = (proc->frame_rx + proc->frame_offset)&1023; *subframe = proc->subframe_rx; } @@ -1452,7 +1467,7 @@ static void* eNB_thread_single( void* param ) { eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq2; } - eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,1); } // if RRU and slave @@ -1528,6 +1543,7 @@ void init_eNB_proc(int inst) { proc->first_rx=1; proc->first_tx=1; + proc->frame_offset = 0; pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); From a4bdaddaaf18e98019880f3e0ce4a4958f5fb8da Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 14:05:36 +0800 Subject: [PATCH 23/59] commit from other machine prior to merge --- targets/RT/USER/lte-enb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5024154f40..6af84b605d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -761,13 +761,11 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { else { if (frame_tx != *frame) { LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - *frame = frame_tx; - // exit_fun("Exiting"); + exit_fun("Exiting"); } if (subframe_tx != *subframe) { LOG_E(PHY,"fh_if4p5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - *subframe = subframe_tx; - // exit_fun("Exiting"); + exit_fun("Exiting"); } } if (packet_type == IF4p5_PDLFFT) { From 8df3f84fc455917f99d2ae2c5ddbd1f77d28dfaa Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 14:36:22 +0800 Subject: [PATCH 24/59] small change in if4p5_asynch_DL --- targets/RT/USER/lte-enb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 49b9bd4d0c..693653c9c9 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -760,7 +760,6 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { else { if (frame_tx != *frame) { LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - *frame = frame_tx; // exit_fun("Exiting"); } if (subframe_tx != *subframe) { @@ -778,6 +777,8 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } } while (proc->symbol_mask[*subframe] != symbol_mask_full); + *frame = frame_tx; + // intialize this to zero after we're done with the subframe proc->symbol_mask[*subframe] = 0; From 085718ae8b2fd360231d02f17d09737be44fac89 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 23 Nov 2016 19:12:02 +0800 Subject: [PATCH 25/59] RRU synchronization debugging --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 6 ++++-- openair1/PHY/defs.h | 4 ++++ targets/RT/USER/lte-enb.c | 11 ++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 1aff7d876b..4ecdd6688d 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -119,7 +119,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type gen_IF4p5_ul_header(packet_header, frame, subframe); for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - + LOG_I(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); for (element_id=0; element_idflags == ETH_RAW_IF4p5_MODE) { packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES); @@ -229,11 +230,12 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t *packet_type = packet_header->sub_type; - // LOG_I(PHY,"CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe); if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; + LOG_I(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); + slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 9ba1c53d64..b1fdf544b7 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -244,6 +244,10 @@ typedef struct eNB_proc_t_s { int subframe_prach; /// frame to act upon for reception int frame_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame offset for secondary eNBs (to correct for frame asynchronism at startup) + int frame_offset; /// frame to act upon for PRACH int frame_prach; /// \internal This variable is protected by \ref mutex_fep. diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 693653c9c9..97c877c8ea 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -756,6 +756,7 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { *frame = frame_tx; *subframe = subframe_tx; proc->first_tx = 0; + proc->frame_offset = frame_tx - proc->frame_tx; } else { if (frame_tx != *frame) { @@ -779,6 +780,7 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { *frame = frame_tx; + // intialize this to zero after we're done with the subframe proc->symbol_mask[*subframe] = 0; @@ -906,6 +908,9 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; proc->subframe_rx = ((proc->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; + proc->frame_rx = (proc->frame_rx+proc->frame_offset)%1023; + proc->frame_tx = proc->frame_rx; + if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)%1023; // synchronize first reception to frame 0 subframe 0 proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); @@ -916,8 +921,8 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); exit_fun("Exiting"); } - - if (proc->frame_rx != *frame) { + int f2 = *frame+proc->frame_offset; + if (proc->frame_rx != f2) { LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->timestamp_rx,proc->frame_rx,*frame); exit_fun("Exiting"); } @@ -1495,7 +1500,7 @@ static void* eNB_thread_single( void* param ) { proc_rxtx->subframe_rx = proc->subframe_rx; proc_rxtx->frame_rx = proc->frame_rx; proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10; - proc_rxtx->frame_tx = (proc->subframe_rx < 6) ? proc->frame_rx : (proc->frame_rx+1)&1023; + proc_rxtx->frame_tx = proc->frame_tx; proc_rxtx->timestamp_tx = proc->timestamp_tx; // At this point, all information for subframe has been received on FH interface From 8bc94223b411e6b0a9426691cf4ced2581f79bc4 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 24 Nov 2016 15:55:00 +0800 Subject: [PATCH 26/59] remove debugging traces from lte-enb.c and if4_tools.c. modulo 1024 bug on frame counter in lte-enb.c --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 6 +++--- targets/RT/USER/lte-enb.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 4ecdd6688d..97f3cd9ae9 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -119,7 +119,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type gen_IF4p5_ul_header(packet_header, frame, subframe); for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - LOG_I(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); + LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); for (element_id=0; element_idflags == ETH_RAW_IF4p5_MODE) { packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES); @@ -234,7 +234,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; - LOG_I(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); + LOG_D(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 97c877c8ea..eadff1ffe3 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -908,9 +908,9 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; proc->subframe_rx = ((proc->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; - proc->frame_rx = (proc->frame_rx+proc->frame_offset)%1023; + proc->frame_rx = (proc->frame_rx+proc->frame_offset)&1023; proc->frame_tx = proc->frame_rx; - if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)%1023; + if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023; // synchronize first reception to frame 0 subframe 0 proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); @@ -921,9 +921,9 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); exit_fun("Exiting"); } - int f2 = *frame+proc->frame_offset; + int f2 = (*frame+proc->frame_offset)&1023; if (proc->frame_rx != f2) { - LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->timestamp_rx,proc->frame_rx,*frame); + LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, frame_offset %d, f2 %d)\n",proc->timestamp_rx,proc->frame_rx,*frame,proc->frame_offset,f2); exit_fun("Exiting"); } } else { From eb854b8e6ace3efe65f95865a43b35f3f6870d33 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 24 Nov 2016 15:56:38 +0800 Subject: [PATCH 27/59] setting of frame_tx in lte-enb.c --- cmake_targets/CMakeLists.txt | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- targets/RT/USER/lte-enb.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c1507de61b..5e86d59378 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") -add_integer_option(MAX_NUM_CCs 2 "????") +add_integer_option(MAX_NUM_CCs 1 "????") add_boolean_option(MU_RECEIVER False "????") add_boolean_option(NEW_FFT True "????") add_boolean_option(OPENAIR1 True "????") diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 0ee6c1ff11..359cb86776 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1925,7 +1925,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) { eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits eNB->UE_stats[(uint32_t)UE_id].sector = 0; - LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", + LOG_D(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", eNB->Mod_id, eNB->CC_id, frame, diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index e2f776187f..15e45fc3f6 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1516,7 +1516,8 @@ static void* eNB_thread_single( void* param ) { proc_rxtx->subframe_rx = proc->subframe_rx; proc_rxtx->frame_rx = proc->frame_rx; proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10; - proc_rxtx->frame_tx = proc->frame_tx; + proc_rxtx->frame_tx = (proc->subframe_rx>5) ? (1+proc->frame_rx)&1023 : proc->frame_rx; + proc->frame_tx = proc_rxtx->frame_tx; proc_rxtx->timestamp_tx = proc->timestamp_tx; // adjust for timing offset between RRU if (eNB->CC_id!=0) proc_rxtx->frame_tx = (proc_rxtx->frame_tx+proc->frame_offset)&1023; From f1bd8ba02af52082ad039bae4376e26ccef18db9 Mon Sep 17 00:00:00 2001 From: "S. Sandeep Kumar" Date: Thu, 24 Nov 2016 17:34:48 +0530 Subject: [PATCH 28/59] fix conflicting prach size in if4p5 --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 56799ea894..2afb6ff019 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -150,7 +150,7 @@ 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 LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe); - db_fulllength = 840*2; + db_fulllength = PRACH_HARD_CODED_SIZE; 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); diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h index 855ff49704..c06656f2dc 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h @@ -60,7 +60,8 @@ // Packet sizes for IF4p5 interface format #define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(uint16_t)*scaled_nblocks) -#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*839*2) // FIX hard coded prach size (uncompressed) +#define PRACH_HARD_CODED_SIZE (839*2) +#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*PRACH_HARD_CODED_SIZE) // FIX hard coded prach size #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)) From fe10da264217ce77324d4f6d5aad7cad731ea4a6 Mon Sep 17 00:00:00 2001 From: "S. Sandeep Kumar" Date: Thu, 24 Nov 2016 19:14:50 +0530 Subject: [PATCH 29/59] fix conflicting prach size in if4p5 --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 2afb6ff019..9e5fc19d3b 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -150,7 +150,8 @@ 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 LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe); - db_fulllength = PRACH_HARD_CODED_SIZE; + db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES; + 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); @@ -163,11 +164,11 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type 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)); + PRACH_BLOCK_SIZE_BYTES); } else { memcpy((int16_t*)(tx_buffer + sizeof_IF4p5_header_t), (&rxsigF[0][k]), - db_fulllength*sizeof(int16_t)); + PRACH_BLOCK_SIZE_BYTES); } if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice, @@ -273,16 +274,16 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t } else if (*packet_type == IF4p5_PRACH) { // FIX: hard coded prach samples length - db_fulllength = 840*2; + db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES; 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)); + PRACH_BLOCK_SIZE_BYTES); } else { memcpy((&rxsigF[0][0]), (int16_t*) (rx_buffer+sizeof_IF4p5_header_t), - db_fulllength*sizeof(int16_t)); + PRACH_BLOCK_SIZE_BYTES); } } else { From 03eb2c498dd23bd45f0a02fce171403a2eca24b6 Mon Sep 17 00:00:00 2001 From: "S. Sandeep Kumar" Date: Thu, 24 Nov 2016 19:27:57 +0530 Subject: [PATCH 30/59] missed to commit changes for if_defs.h file --- targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h index c06656f2dc..af882660a6 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h @@ -60,8 +60,8 @@ // Packet sizes for IF4p5 interface format #define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(uint16_t)*scaled_nblocks) -#define PRACH_HARD_CODED_SIZE (839*2) -#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*PRACH_HARD_CODED_SIZE) // FIX hard coded prach size +#define PRACH_HARD_CODED_NUM_SAMPLES (839*2) +#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*PRACH_HARD_CODED_NUM_SAMPLES) // FIX hard coded prach size #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)) From 2774702108039d24cb3ae2644a4f28ec56f28ef5 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Thu, 1 Dec 2016 21:36:33 +0100 Subject: [PATCH 31/59] IF5 timing for RCC --- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf | 8 ++++---- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf | 9 +++++---- targets/RT/USER/lte-enb.c | 5 ++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf index 7890736e5e..fe7719f852 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf @@ -157,13 +157,13 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth2"; - remote_address = "00:13:95:1f:a0:af"; - local_address = "90:e2:ba:c5:fc:04"; + local_if_name = "eth0"; + remote_address = "10.10.10.60"; + local_address = "10.10.10.215"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf index e8ffde20b6..1d1c51c137 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf @@ -36,6 +36,7 @@ eNBs = Nid_cell = 0; N_RB_DL = 25; Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; tx_gain = 90; @@ -100,7 +101,7 @@ eNBs = ue_TimersAndConstants_t311 = 10000; ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; - + ue_TransmissionMode = 1; } ); @@ -156,12 +157,12 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "74:d4:35:cc:8d:15"; - local_address = "34:e6:d7:3c:ae:fc"; + remote_address = "10.10.10.60"; + local_address = "10.10.10.215"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ee92a580c2..24f52a69db 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -969,6 +969,8 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { *frame = proc->frame_rx; *subframe = proc->subframe_rx; } + + proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); @@ -1504,7 +1506,8 @@ static void* eNB_thread_single( void* param ) { subframe++; } - if (eNB->CC_id==1) LOG_I(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", + if (eNB->CC_id==1) + LOG_I(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe); // synchronization on FH interface, acquire signals/data and block From 8678be1692c64ec3f04fc9be62c3cb459b405cf4 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 2 Dec 2016 05:36:23 +0100 Subject: [PATCH 32/59] fixed IF5 timing --- openair2/ENB_APP/enb_config.c | 2 +- targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c | 1 + .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf | 8 ++++---- .../CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf | 2 +- targets/RT/USER/lte-enb.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index d4c6a81c4f..7d90c194a6 100755 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2369,7 +2369,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rawif5_mobipass = 1; } else {//if (strcmp(preference, "no") == 0) enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 1; - enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1; + enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1; } if (strcmp(rf_preference, "exmimo") == 0) { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 67ad93f044..7991e6a240 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -101,6 +101,7 @@ int trx_eth_start(openair0_device *device) { printf("Setting ETHERNET to RAW_IF5_MODE\n"); if (eth_socket_init_raw(device)!=0) return -1; } else { + printf("Setting ETHERNET to UDP_IF5_MODE\n"); if (eth_socket_init_udp(device)!=0) return -1; /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ if (device->host_type == BBU_HOST) { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf index 7890736e5e..fe7719f852 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf @@ -157,13 +157,13 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth2"; - remote_address = "00:13:95:1f:a0:af"; - local_address = "90:e2:ba:c5:fc:04"; + local_if_name = "eth0"; + remote_address = "10.10.10.60"; + local_address = "10.10.10.215"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf index 7f92dff947..c97b215c77 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.usrpb210.conf @@ -160,7 +160,7 @@ eNBs = { local_if_name = "eth0"; remote_address = "10.10.10.155"; - local_address = "10.10.10.58"; + local_address = "10.10.10.60"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ee92a580c2..418c0d6a67 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -717,7 +717,7 @@ void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { openair0_timestamp timestamp_tx; recv_IF5(eNB, ×tamp_tx, *subframe, IF5_RRH_GW_DL); - // printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); + //printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; From 8aa61a1d292323b0f236b0dec1b586d22383a61d Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Thu, 1 Dec 2016 23:32:07 +0100 Subject: [PATCH 33/59] new IF5 configuration file --- .../CONF/rcc.band7.tm1.if5.25PRB.conf | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf new file mode 100644 index 0000000000..6987bebda9 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf @@ -0,0 +1,191 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP_BBU"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2660000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -29; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -96; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "127.0.0.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; + ENB_INTERFACE_NAME_FOR_S1U = "lo"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "eth0"; + remote_address = "10.10.10.60"; + local_address = "10.10.10.215"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); From cfc308dd4cb99524a52c03645096682ba09ba59c Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 2 Dec 2016 07:35:34 +0100 Subject: [PATCH 34/59] new IF5 configuration file for RRU --- .../rru.band7.tm1.if5.25PRB.usrpb210.conf | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.25PRB.usrpb210.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.25PRB.usrpb210.conf new file mode 100644 index 0000000000..71e435e2f4 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.25PRB.usrpb210.conf @@ -0,0 +1,193 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RRU_IF5"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 120; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -29; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -95; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -104; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.11"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "eth0"; + remote_address = "10.10.10.155"; + local_address = "10.10.10.60"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); From eb826088781db510e9864005dbfb541102393582 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 2 Dec 2016 09:57:20 +0100 Subject: [PATCH 35/59] dos2unix on eth_udp.c --- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 966 +++++++++--------- 1 file changed, 483 insertions(+), 483 deletions(-) diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index d507385dd4..4163d99c34 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -1,483 +1,483 @@ -/******************************************************************************* - OpenAirInterface - Copyright(c) 1999 - 2014 Eurecom - - OpenAirInterface is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - - OpenAirInterface is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OpenAirInterface.The full GNU General Public License is - included in this distribution in the file called "COPYING". If not, - see . - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE - - *******************************************************************************/ -/*! \file ethernet_lib.c - * \brief API to stream I/Q samples over standard ethernet - * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp - * \date 2015 - * \version 0.2 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "vcd_signal_dumper.h" - -#include "common_lib.h" -#include "ethernet_lib.h" - -#define DEBUG 0 -//struct sockaddr_in dest_addr[MAX_INST]; -//struct sockaddr_in local_addr[MAX_INST]; -//int addr_len[MAX_INST]; - - -uint16_t pck_seq_num = 1; -uint16_t pck_seq_num_cur=0; -uint16_t pck_seq_num_prev=0; - -int eth_socket_init_udp(openair0_device *device) { - - eth_state_t *eth = (eth_state_t*)device->priv; - char str_local[INET_ADDRSTRLEN]; - char str_remote[INET_ADDRSTRLEN]; - const char *local_ip, *remote_ip; - int local_port=0, remote_port=0; - int sock_dom=0; - int sock_type=0; - int sock_proto=0; - int enable=1; - - if (device->host_type == RRH_HOST ) { - local_ip = device->openair0_cfg->my_addr; - local_port = device->openair0_cfg->my_port; - remote_ip = "0.0.0.0"; - remote_port = 0; - printf("[%s] local ip addr %s port %d\n", "RRH", local_ip, local_port); - } else { - local_ip = device->openair0_cfg->my_addr; - local_port = device->openair0_cfg->my_port; - remote_ip = device->openair0_cfg->remote_addr; - remote_port = device->openair0_cfg->remote_port; - printf("[%s] local ip addr %s port %d\n","BBU", local_ip, local_port); - } - - /* Open socket to send on */ - sock_dom=AF_INET; - sock_type=SOCK_DGRAM; - sock_proto=IPPROTO_UDP; - - if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) { - perror("ETHERNET: Error opening socket"); - exit(0); - } - - /* initialize addresses */ - bzero((void *)&(eth->dest_addr), sizeof(eth->dest_addr)); - bzero((void *)&(eth->local_addr), sizeof(eth->local_addr)); - - - eth->addr_len = sizeof(struct sockaddr_in); - - eth->dest_addr.sin_family = AF_INET; - inet_pton(AF_INET,remote_ip,&(eth->dest_addr.sin_addr.s_addr)); - eth->dest_addr.sin_port=htons(remote_port); - inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN); - - - eth->local_addr.sin_family = AF_INET; - inet_pton(AF_INET,local_ip,&(eth->local_addr.sin_addr.s_addr)); - eth->local_addr.sin_port=htons(local_port); - inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str_local, INET_ADDRSTRLEN); - - - /* set reuse address flag */ - if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { - perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); - exit(0); - } - - /* want to receive -> so bind */ - if (bind(eth->sockfd,(struct sockaddr *)ð->local_addr,eth->addr_len)<0) { - perror("ETHERNET: Cannot bind to socket"); - exit(0); - } else { - printf("[%s] binding to %s:%d\n","RRH",str_local,ntohs(eth->local_addr.sin_port)); - } - - return 0; -} - -int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - - // Read nblocks info from packet itself - int nblocks = nsamps; - int bytes_received=-1; - eth_state_t *eth = (eth_state_t*)device->priv; - - ssize_t packet_size = sizeof_IF4p5_header_t; - IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); - - int block_cnt=0; - int again_cnt=0; - packet_size = max(UDP_IF4p5_PRACH_SIZE_BYTES, max(UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks), UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks))); - - while(bytes_received == -1) { - again: - bytes_received = recvfrom(eth->sockfd, - buff[0], - packet_size, - 0, - (struct sockaddr *)ð->dest_addr, - (socklen_t *)ð->addr_len); - if (bytes_received ==-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; - } - */ - printf("Lost IF4p5 connection with %s\n", inet_ntoa(eth->dest_addr.sin_addr)); - exit(-1); - } 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 { - *timestamp = test_header->sub_type; - eth->rx_actual_nsamps = bytes_received>>1; - eth->rx_count++; - } - } - //printf("size of third %d subtype %d frame %d subframe %d symbol %d \n", bytes_received, test_header->sub_type, ((test_header->frame_status)>>6)&0xffff, ((test_header->frame_status)>>22)&0x000f, ((test_header->frame_status)>>26)&0x000f) ; - - eth->rx_nsamps = nsamps; - return(bytes_received); -} - -int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - - int nblocks = nsamps; - int bytes_sent = 0; - - eth_state_t *eth = (eth_state_t*)device->priv; - - ssize_t packet_size; - - if (flags == IF4p5_PDLFFT) { - packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); - } else if (flags == IF4p5_PULFFT) { - packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); - } else if (flags == IF4p5_PRACH) { - packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; - } else { - printf("trx_eth_write_udp_IF4p5: unknown flags %d\n",flags); - return(-1); - } - - eth->tx_nsamps = nblocks; - - bytes_sent = sendto(eth->sockfd, - buff[0], - packet_size, - 0, - (struct sockaddr*)ð->dest_addr, - eth->addr_len); - - if (bytes_sent == -1) { - eth->num_tx_errors++; - perror("ETHERNET WRITE: "); - exit(-1); - } else { - eth->tx_actual_nsamps = bytes_sent>>1; - eth->tx_count++; - } - - return (bytes_sent); -} - -int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags) { - - int bytes_sent=0; - eth_state_t *eth = (eth_state_t*)device->priv; - int sendto_flag =0; - int i=0; - //sendto_flag|=flags; - eth->tx_nsamps=nsamps; - - for (i=0;ipck_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 + 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); - - while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) { -#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, - bytes_sent); -#endif - /* Send packet */ - bytes_sent += sendto(eth->sockfd, - buff2, - UDP_PACKET_SIZE_BYTES(nsamps), - sendto_flag, - (struct sockaddr*)ð->dest_addr, - eth->addr_len); - - if ( bytes_sent == -1) { - eth->num_tx_errors++; - perror("ETHERNET WRITE: "); - exit(-1); - } else { -#if DEBUG - printf("------- TX ------: nu=%d an_id=%d ts%d bytes_send=%d\n", - *(int16_t *)buff2, - *(int16_t *)(buff2 + sizeof(int16_t)), - *(openair0_timestamp *)(buff2 + sizeof(int32_t)), - bytes_sent); - dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; - } - } - /* tx buffer values restored */ - *(int32_t *)buff2 = temp0; - *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; - } - - return (bytes_sent-APP_HEADER_SIZE_BYTES)>>2; -} - - - -int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - - int bytes_received=0; - eth_state_t *eth = (eth_state_t*)device->priv; - // openair0_timestamp prev_timestamp = -1; - int rcvfrom_flag =0; - int block_cnt=0; - int again_cnt=0; - int i=0; - - eth->rx_nsamps=nsamps; - - for (i=0;isockfd, - buff2, - UDP_PACKET_SIZE_BYTES(nsamps), - rcvfrom_flag, - (struct sockaddr *)ð->dest_addr, - (socklen_t *)ð->addr_len); - - if (bytes_received ==-1) { - eth->num_rx_errors++; - if (errno == EAGAIN) { - again_cnt++; - usleep(10); - if (again_cnt == 1000) { - perror("ETHERNET READ: "); - 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 READ: "); - exit(-1); - } else { - printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n"); - goto again; - } - } - } else { -#if DEBUG - printf("------- RX------: nu=%d an_id=%d ts%d bytes_recv=%d\n", - *(int16_t *)buff2, - *(int16_t *)(buff2 + sizeof(int16_t)), - *(openair0_timestamp *)(buff2 + sizeof(int32_t)), - bytes_received); - dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; - } else { - pck_seq_num_prev = 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); - } - 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); - eth->rx_actual_nsamps=bytes_received>>2; - eth->rx_count++; - } - - } - /* tx buffer values restored */ - *(int32_t *)buff2 = temp0; - *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; - - } - return (bytes_received-APP_HEADER_SIZE_BYTES)>>2; -} - - - - -int eth_set_dev_conf_udp(openair0_device *device) { - - eth_state_t *eth = (eth_state_t*)device->priv; - void *msg; - ssize_t msg_len; - - - /* a BBU client sents to RRH a set of configuration parameters (openair0_config_t) - so that RF front end is configured appropriately and - frame/packet size etc. can be set */ - - msg=malloc(sizeof(openair0_config_t)); - msg_len=sizeof(openair0_config_t); - memcpy(msg,(void*)device->openair0_cfg,msg_len); - - if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->dest_addr,eth->addr_len)==-1) { - perror("ETHERNET: sendto conf_udp"); - printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len); - exit(0); - } - - return 0; -} - -int eth_get_dev_conf_udp(openair0_device *device) { - - eth_state_t *eth = (eth_state_t*)device->priv; - char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN]; - void *msg; - ssize_t msg_len; - - msg=malloc(sizeof(openair0_config_t)); - msg_len=sizeof(openair0_config_t); - - inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); - inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); - - /* RRH receives from BBU openair0_config_t */ - if (recvfrom(eth->sockfd, - msg, - msg_len, - 0, - (struct sockaddr *)ð->dest_addr, - (socklen_t *)ð->addr_len)==-1) { - perror("ETHERNET: recv_from conf_udp"); - exit(0); - } - device->openair0_cfg=(openair0_config_t *)msg; - - /* get remote ip address and port */ - /* inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->remote_port =ntohs(eth->dest_addr.sin_port); */ - /* device->openair0_cfg->remote_addr =str1; */ - - /* /\* restore local ip address and port *\/ */ - /* inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); */ - /* device->openair0_cfg->my_port =ntohs(eth->local_addr.sin_port); */ - /* device->openair0_cfg->my_addr =str; */ - - /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ - return 0; -} +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + + *******************************************************************************/ +/*! \file ethernet_lib.c + * \brief API to stream I/Q samples over standard ethernet + * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp + * \date 2015 + * \version 0.2 + * \company Eurecom + * \maintainer: navid.nikaein@eurecom.fr + * \note + * \warning + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vcd_signal_dumper.h" + +#include "common_lib.h" +#include "ethernet_lib.h" + +#define DEBUG 0 +//struct sockaddr_in dest_addr[MAX_INST]; +//struct sockaddr_in local_addr[MAX_INST]; +//int addr_len[MAX_INST]; + + +uint16_t pck_seq_num = 1; +uint16_t pck_seq_num_cur=0; +uint16_t pck_seq_num_prev=0; + +int eth_socket_init_udp(openair0_device *device) { + + eth_state_t *eth = (eth_state_t*)device->priv; + char str_local[INET_ADDRSTRLEN]; + char str_remote[INET_ADDRSTRLEN]; + const char *local_ip, *remote_ip; + int local_port=0, remote_port=0; + int sock_dom=0; + int sock_type=0; + int sock_proto=0; + int enable=1; + + if (device->host_type == RRH_HOST ) { + local_ip = device->openair0_cfg->my_addr; + local_port = device->openair0_cfg->my_port; + remote_ip = "0.0.0.0"; + remote_port = 0; + printf("[%s] local ip addr %s port %d\n", "RRH", local_ip, local_port); + } else { + local_ip = device->openair0_cfg->my_addr; + local_port = device->openair0_cfg->my_port; + remote_ip = device->openair0_cfg->remote_addr; + remote_port = device->openair0_cfg->remote_port; + printf("[%s] local ip addr %s port %d\n","BBU", local_ip, local_port); + } + + /* Open socket to send on */ + sock_dom=AF_INET; + sock_type=SOCK_DGRAM; + sock_proto=IPPROTO_UDP; + + if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) { + perror("ETHERNET: Error opening socket"); + exit(0); + } + + /* initialize addresses */ + bzero((void *)&(eth->dest_addr), sizeof(eth->dest_addr)); + bzero((void *)&(eth->local_addr), sizeof(eth->local_addr)); + + + eth->addr_len = sizeof(struct sockaddr_in); + + eth->dest_addr.sin_family = AF_INET; + inet_pton(AF_INET,remote_ip,&(eth->dest_addr.sin_addr.s_addr)); + eth->dest_addr.sin_port=htons(remote_port); + inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN); + + + eth->local_addr.sin_family = AF_INET; + inet_pton(AF_INET,local_ip,&(eth->local_addr.sin_addr.s_addr)); + eth->local_addr.sin_port=htons(local_port); + inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str_local, INET_ADDRSTRLEN); + + + /* set reuse address flag */ + if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { + perror("ETHERNET: Cannot set SO_REUSEADDR option on socket"); + exit(0); + } + + /* want to receive -> so bind */ + if (bind(eth->sockfd,(struct sockaddr *)ð->local_addr,eth->addr_len)<0) { + perror("ETHERNET: Cannot bind to socket"); + exit(0); + } else { + printf("[%s] binding to %s:%d\n","RRH",str_local,ntohs(eth->local_addr.sin_port)); + } + + return 0; +} + +int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { + + // Read nblocks info from packet itself + int nblocks = nsamps; + int bytes_received=-1; + eth_state_t *eth = (eth_state_t*)device->priv; + + ssize_t packet_size = sizeof_IF4p5_header_t; + IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); + + int block_cnt=0; + int again_cnt=0; + packet_size = max(UDP_IF4p5_PRACH_SIZE_BYTES, max(UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks), UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks))); + + while(bytes_received == -1) { + again: + bytes_received = recvfrom(eth->sockfd, + buff[0], + packet_size, + 0, + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len); + if (bytes_received ==-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; + } + */ + printf("Lost IF4p5 connection with %s\n", inet_ntoa(eth->dest_addr.sin_addr)); + exit(-1); + } 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 { + *timestamp = test_header->sub_type; + eth->rx_actual_nsamps = bytes_received>>1; + eth->rx_count++; + } + } + //printf("size of third %d subtype %d frame %d subframe %d symbol %d \n", bytes_received, test_header->sub_type, ((test_header->frame_status)>>6)&0xffff, ((test_header->frame_status)>>22)&0x000f, ((test_header->frame_status)>>26)&0x000f) ; + + eth->rx_nsamps = nsamps; + return(bytes_received); +} + +int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { + + int nblocks = nsamps; + int bytes_sent = 0; + + eth_state_t *eth = (eth_state_t*)device->priv; + + ssize_t packet_size; + + if (flags == IF4p5_PDLFFT) { + packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PULFFT) { + packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PRACH) { + packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; + } else { + printf("trx_eth_write_udp_IF4p5: unknown flags %d\n",flags); + return(-1); + } + + eth->tx_nsamps = nblocks; + + bytes_sent = sendto(eth->sockfd, + buff[0], + packet_size, + 0, + (struct sockaddr*)ð->dest_addr, + eth->addr_len); + + if (bytes_sent == -1) { + eth->num_tx_errors++; + perror("ETHERNET WRITE: "); + exit(-1); + } else { + eth->tx_actual_nsamps = bytes_sent>>1; + eth->tx_count++; + } + + return (bytes_sent); +} + +int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags) { + + int bytes_sent=0; + eth_state_t *eth = (eth_state_t*)device->priv; + int sendto_flag =0; + int i=0; + //sendto_flag|=flags; + eth->tx_nsamps=nsamps; + + for (i=0;ipck_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 + 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); + + while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) { +#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, + bytes_sent); +#endif + /* Send packet */ + bytes_sent += sendto(eth->sockfd, + buff2, + UDP_PACKET_SIZE_BYTES(nsamps), + sendto_flag, + (struct sockaddr*)ð->dest_addr, + eth->addr_len); + + if ( bytes_sent == -1) { + eth->num_tx_errors++; + perror("ETHERNET WRITE: "); + exit(-1); + } else { +#if DEBUG + printf("------- TX ------: nu=%d an_id=%d ts%d bytes_send=%d\n", + *(int16_t *)buff2, + *(int16_t *)(buff2 + sizeof(int16_t)), + *(openair0_timestamp *)(buff2 + sizeof(int32_t)), + bytes_sent); + dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; + } + } + /* tx buffer values restored */ + *(int32_t *)buff2 = temp0; + *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; + } + + return (bytes_sent-APP_HEADER_SIZE_BYTES)>>2; +} + + + +int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { + + int bytes_received=0; + eth_state_t *eth = (eth_state_t*)device->priv; + // openair0_timestamp prev_timestamp = -1; + int rcvfrom_flag =0; + int block_cnt=0; + int again_cnt=0; + int i=0; + + eth->rx_nsamps=nsamps; + + for (i=0;isockfd, + buff2, + UDP_PACKET_SIZE_BYTES(nsamps), + rcvfrom_flag, + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len); + + if (bytes_received ==-1) { + eth->num_rx_errors++; + if (errno == EAGAIN) { + again_cnt++; + usleep(10); + if (again_cnt == 1000) { + perror("ETHERNET READ: "); + 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 READ: "); + exit(-1); + } else { + printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n"); + goto again; + } + } + } else { +#if DEBUG + printf("------- RX------: nu=%d an_id=%d ts%d bytes_recv=%d\n", + *(int16_t *)buff2, + *(int16_t *)(buff2 + sizeof(int16_t)), + *(openair0_timestamp *)(buff2 + sizeof(int32_t)), + bytes_received); + dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", 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; + } else { + pck_seq_num_prev = 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); + } + 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); + eth->rx_actual_nsamps=bytes_received>>2; + eth->rx_count++; + } + + } + /* tx buffer values restored */ + *(int32_t *)buff2 = temp0; + *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; + + } + return (bytes_received-APP_HEADER_SIZE_BYTES)>>2; +} + + + + +int eth_set_dev_conf_udp(openair0_device *device) { + + eth_state_t *eth = (eth_state_t*)device->priv; + void *msg; + ssize_t msg_len; + + + /* a BBU client sents to RRH a set of configuration parameters (openair0_config_t) + so that RF front end is configured appropriately and + frame/packet size etc. can be set */ + + msg=malloc(sizeof(openair0_config_t)); + msg_len=sizeof(openair0_config_t); + memcpy(msg,(void*)device->openair0_cfg,msg_len); + + if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)ð->dest_addr,eth->addr_len)==-1) { + perror("ETHERNET: sendto conf_udp"); + printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len); + exit(0); + } + + return 0; +} + +int eth_get_dev_conf_udp(openair0_device *device) { + + eth_state_t *eth = (eth_state_t*)device->priv; + char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN]; + void *msg; + ssize_t msg_len; + + msg=malloc(sizeof(openair0_config_t)); + msg_len=sizeof(openair0_config_t); + + inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); + + /* RRH receives from BBU openair0_config_t */ + if (recvfrom(eth->sockfd, + msg, + msg_len, + 0, + (struct sockaddr *)ð->dest_addr, + (socklen_t *)ð->addr_len)==-1) { + perror("ETHERNET: recv_from conf_udp"); + exit(0); + } + device->openair0_cfg=(openair0_config_t *)msg; + + /* get remote ip address and port */ + /* inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->remote_port =ntohs(eth->dest_addr.sin_port); */ + /* device->openair0_cfg->remote_addr =str1; */ + + /* /\* restore local ip address and port *\/ */ + /* inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); */ + /* device->openair0_cfg->my_port =ntohs(eth->local_addr.sin_port); */ + /* device->openair0_cfg->my_addr =str; */ + + /* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */ + return 0; +} From 0717c18ccbe69ddc1d31bfaf511747c515348d8d Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sun, 4 Dec 2016 12:11:03 +0100 Subject: [PATCH 36/59] modifications for PRACH on IF4p5 --- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- ...RB.if4p5.conf => rcc.band7.tm1.if4p5.50PRB.conf} | 0 targets/RT/USER/lte-enb.c | 13 ++++++------- 3 files changed, 7 insertions(+), 8 deletions(-) rename targets/PROJECTS/GENERIC-LTE-EPC/CONF/{rcc.band7.tm1.50PRB.if4p5.conf => rcc.band7.tm1.if4p5.50PRB.conf} (100%) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 5725713e42..fe9fc68abe 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1916,7 +1916,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) { eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits eNB->UE_stats[(uint32_t)UE_id].sector = 0; - LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", + LOG_D(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", eNB->Mod_id, eNB->CC_id, frame, diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 958a5069a1..020e5b944f 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -543,7 +543,8 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // **************************************** // Common RX procedures subframe n - if (eNB->do_prach) eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx); + if ((eNB->do_prach)&&((eNB->node_function != NGFI_RCC_IF4p5))) + eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx); phy_procedures_eNB_common_RX(eNB); // UE-specific RX processing for subframe n @@ -980,34 +981,32 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { eNB_proc_t *proc = &eNB->proc; int f,sf; - int prach_rx; - uint16_t packet_type; uint32_t symbol_number=0; uint32_t symbol_mask, symbol_mask_full; symbol_mask_full = (1<symbols_per_tti)-1; - prach_rx = (is_prach_subframe(fp, *frame, *subframe)>0) ? 1 : 0; if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: frame %d, subframe %d\n",*frame,*subframe); do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(eNB, &f, &sf, &packet_type, &symbol_number); //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; if (packet_type == IF4p5_PULFFT) { + LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); proc->subframe_rx = sf; proc->frame_rx = f; proc->symbol_mask[proc->subframe_rx] = proc->symbol_mask[proc->subframe_rx] | (1<do_prach) eNB->do_prach(eNB,f,sf); } - if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x, prach %d\n",*subframe,proc->symbol_mask[*subframe],prach_rx); + if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]); - } while( (proc->symbol_mask[*subframe] != symbol_mask_full) || (prach_rx == 1)); + } while(proc->symbol_mask[*subframe] != symbol_mask_full); proc->symbol_mask[*subframe] = 0; proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event From 76ee52a635bc1c15aab1474b466e1e087cd215d2 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 4 Dec 2016 17:49:25 +0100 Subject: [PATCH 37/59] small changes for rru debugging --- .../rru.band7.tm1.if4p5.100PRB.usrpb210.conf | 21 +++++++++++-------- .../rru.band7.tm1.if4p5.50PRB.usrpb210.conf | 8 +++---- targets/RT/USER/lte-enb.c | 10 +++++++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf index b1c4298104..664bbec846 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf @@ -31,15 +31,16 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2680000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 100; Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; - tx_gain = 90; - rx_gain = 125; + tx_gain = 90; + rx_gain = 120; prach_root = 0; prach_config_index = 0; prach_high_speed = "DISABLE"; @@ -67,9 +68,9 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -90; + pusch_p0_Nominal = -95; pusch_alpha = "AL1"; - pucch_p0_Nominal = -96; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -85,7 +86,7 @@ eNBs = rach_messagePowerOffsetGroupB = ; */ rach_powerRampingStep = 4; - rach_preambleInitialReceivedTargetPower = -108; + rach_preambleInitialReceivedTargetPower = -104; rach_preambleTransMax = 10; rach_raResponseWindowSize = 10; rach_macContentionResolutionTimer = 48; @@ -101,6 +102,8 @@ eNBs = ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } ); @@ -156,12 +159,12 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "34:e6:d7:3c:ae:fc"; - local_address = "74:d4:35:cc:8d:15"; + remote_address = "10.10.10.155"; + local_address = "10.10.10.60"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf index c8c5b73974..ecbe2f049f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2685000000L; + downlink_frequency = 2660000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; @@ -159,12 +159,12 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "90:e2:ba:c5:fc:04"; - local_address = "00:13:95:1f:a0:af"; + remote_address = "10.10.10.215"; + local_address = "10.10.10.60"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; - tr_preference = "raw_if4p5"; + tr_preference = "udp_if4p5"; rf_preference = "usrp_b200"; iq_txshift = 4; tx_sample_advance = 80; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5df143b67a..01f549645f 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -722,6 +722,9 @@ void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); + if (proc->first_tx != 0) { *subframe = subframe_tx; *frame = frame_tx; @@ -762,12 +765,12 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { else { if (frame_tx != *frame) { LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - // exit_fun("Exiting"); + exit_fun("Exiting"); } if (subframe_tx != *subframe) { LOG_E(PHY,"fh_if4p5_asynch_DL: (frame %d) subframe_tx %d is not what we expect %d\n",frame_tx,subframe_tx,*subframe); //*subframe = subframe_tx; - //exit_fun("Exiting"); + exit_fun("Exiting"); } } if (packet_type == IF4p5_PDLFFT) { @@ -782,6 +785,9 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { *frame = frame_tx; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); + // intialize this to zero after we're done with the subframe proc->symbol_mask[*subframe] = 0; From b0766d70746940439bf3ee8c176a2b4bc02279da Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 4 Dec 2016 20:17:33 +0100 Subject: [PATCH 38/59] added prach buffer for if4p5 processing in RRU. This fixed a critical bug which was seen for bandwidths greater than 5 MHz. RRU tested with 5/10 MHz on 1.5 GHz Atom. --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 31 ++++++++++++++------------ targets/ARCH/COMMON/common_lib.h | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index d17f49ff34..04982a19e6 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -40,10 +40,11 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type, int k) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - int32_t **txdataF = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0]; - int32_t **rxdataF = eNB->common_vars.rxdataF[0]; - int16_t **rxsigF = eNB->prach_vars.rxsigF; - void *tx_buffer = eNB->ifbuffer.tx; + int32_t **txdataF = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0]; + int32_t **rxdataF = eNB->common_vars.rxdataF[0]; + int16_t **rxsigF = eNB->prach_vars.rxsigF; + void *tx_buffer = eNB->ifbuffer.tx; + void *tx_buffer_prach = eNB->ifbuffer.tx_prach; uint16_t symbol_id=0, element_id=0; uint16_t db_fulllength, db_halflength; @@ -145,27 +146,27 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES; if (eth->flags == ETH_RAW_IF4p5_MODE) { - packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES); + packet_header = (IF4p5_header_t *)(tx_buffer_prach + 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); + packet_header = (IF4p5_header_t *)(tx_buffer_prach); + data_block = (uint16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t); } gen_IF4p5_prach_header(packet_header, frame, subframe); if (eth->flags == ETH_RAW_IF4p5_MODE) { - memcpy((int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t), + memcpy((int16_t*)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t), (&rxsigF[0][k]), PRACH_BLOCK_SIZE_BYTES); } else { - memcpy((int16_t*)(tx_buffer + sizeof_IF4p5_header_t), + memcpy((int16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t), (&rxsigF[0][k]), PRACH_BLOCK_SIZE_BYTES); } if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice, symbol_id, - &tx_buffer, + &tx_buffer_prach, db_fulllength, 1, IF4p5_PRACH)) < 0) { @@ -331,10 +332,12 @@ 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); + eNB->ifbuffer.tx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + eNB->ifbuffer.tx_prach = 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); + eNB->ifbuffer.tx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); + eNB->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); + eNB->ifbuffer.rx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); } } diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 7eaa1e0afb..79993dc52c 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -249,6 +249,8 @@ typedef struct { typedef struct { //! Tx buffer for if device void *tx; + //! Tx buffer (PRACH) for if device + void *tx_prach; //! Rx buffer for if device void *rx; } if_buffer_t; From 108cf6bff0d5f40433f80690fce86c8b7d094352 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sun, 4 Dec 2016 12:20:12 +0100 Subject: [PATCH 39/59] renaming of RCC configuration files --- ...and7.tm1.100PRB.if4p5.conf => rcc.band7.tm1.if4p5.100PRB.conf} | 0 ...7.tm1.50PRB.if5.usrpb210.conf => rcc.band7.tm1.if5.50PRB.conf} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename targets/PROJECTS/GENERIC-LTE-EPC/CONF/{rcc.band7.tm1.100PRB.if4p5.conf => rcc.band7.tm1.if4p5.100PRB.conf} (100%) rename targets/PROJECTS/GENERIC-LTE-EPC/CONF/{rcc.band7.tm1.50PRB.if5.usrpb210.conf => rcc.band7.tm1.if5.50PRB.conf} (100%) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.100PRB.if4p5.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.100PRB.if4p5.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if5.usrpb210.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.conf From 12ed6c21f1506d923df4dd0e275821585156a90a Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Thu, 22 Dec 2016 23:16:31 +0100 Subject: [PATCH 40/59] minor changes in lte-enb.c and rcc configuration files --- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf | 2 +- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf | 8 ++++---- targets/RT/USER/lte-enb.c | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf index 3e404e5dc6..5bdfcc7a12 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 25; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf index 6987bebda9..e8e0e6dadb 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 25; @@ -68,9 +68,9 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -90; + pusch_p0_Nominal = -96; pusch_alpha = "AL1"; - pucch_p0_Nominal = -96; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -86,7 +86,7 @@ eNBs = rach_messagePowerOffsetGroupB = ; */ rach_powerRampingStep = 4; - rach_preambleInitialReceivedTargetPower = -108; + rach_preambleInitialReceivedTargetPower = -104; rach_preambleTransMax = 10; rach_raResponseWindowSize = 10; rach_macContentionResolutionTimer = 48; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index eccb09758c..d118056abd 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -643,7 +643,7 @@ static void wait_system_ready (char *message, volatile int *start_flag) { #endif -// asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU) +// asynchronous UL with IF5 (RCC,RAU,eNodeB_BBU) void fh_if5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { eNB_proc_t *proc = &eNB->proc; @@ -964,8 +964,8 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + proc->frame_rx = (proc->timestamp_rx-eNB / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx-eNB / fp->samples_per_tti)%10; if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ @@ -983,6 +983,8 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { *subframe = proc->subframe_rx; } + + proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); From 975342399d85775b9a8e48295de51aa505cc6bbd Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Tue, 27 Dec 2016 21:31:11 +0100 Subject: [PATCH 41/59] bugfix for DCCH2/SRB2 in eNB_scheduler_dlsch.c, demultiplexing SIMD alignment issue in ulsch_decoding.c, IF5 fronthaul modification in lte-enb.c --- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 21 ++++++++++++++--- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 25 +++++++++++---------- targets/RT/USER/lte-enb.c | 4 ++-- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 68f3abc094..8edb1eaf94 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -1440,7 +1440,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, j2+=Q_m; } - + /* To be improved according to alignment of j2 #if defined(__x86_64__)||defined(__i386__) #ifndef __AVX2__ for (iprime=0; iprimee[iprime]) = *((int16x8_t *)&y[j2]); -#endif +#endif + */ + int16_t *yp,*ep; + for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0]; + iprimeulsch_demultiplexing_stats); // printf("after ACKNAK2 c[%d] = %p (iprime %d, G %d)\n",0,ulsch_harq->c[0],iprime,G); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 399fd701ce..573a3401b0 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -814,15 +814,15 @@ schedule_ue_spec( if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", module_idP,frameP,CC_id,TBS-header_len_dcch); - sdu_lengths[0] += mac_rlc_data_req( - module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH, - (char *)&dlsch_buffer[sdu_lengths[0]]); + sdu_lengths[0] = mac_rlc_data_req( + module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DCCH, + (char *)&dlsch_buffer[0]); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0])); @@ -847,7 +847,7 @@ schedule_ue_spec( sdu_length_total = 0; } } - + // check for DCCH1 and update header information (assume 2 byte sub-header) if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) { rlc_status = mac_rlc_status_ind( @@ -860,9 +860,10 @@ schedule_ue_spec( DCCH+1, (TBS-ta_len-header_len_dcch-sdu_length_total)); // transport block set size less allocations for timing advance and // DCCH SDU + sdu_lengths[num_sdus] = 0; if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + LOG_I(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", module_idP,frameP,CC_id,TBS-header_len_dcch-sdu_length_total); sdu_lengths[num_sdus] += mac_rlc_data_req( module_idP, @@ -872,7 +873,7 @@ schedule_ue_spec( ENB_FLAG_YES, MBMS_FLAG_NO, DCCH+1, - (char *)&dlsch_buffer[sdu_lengths[num_sdus]]); + (char *)&dlsch_buffer[sdu_length_total]); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH+1), T_INT(sdu_lengths[num_sdus])); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 911f265b63..c30e726609 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -966,8 +966,8 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); - proc->frame_rx = (proc->timestamp_rx-eNB / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx-eNB / fp->samples_per_tti)%10; + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; if (proc->first_rx == 0) { if (proc->subframe_rx != *subframe){ From 2507933c824fc54d59051335add92eb16e633cb6 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Wed, 28 Dec 2016 11:43:33 +0100 Subject: [PATCH 42/59] bugfix in rrc_eNB_s1AP.c. ue_context_p is used before checking if pointer is non-null. --- openair2/RRC/LITE/rrc_eNB_S1AP.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index a3dc9f47a1..8899c7d743 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -774,8 +774,8 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); - srb_id = ue_context_p->ue_context.Srb2.Srb_info.Srb_id; - + + LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d\n", instance, msg_name, @@ -822,6 +822,9 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( } else { PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + srb_id = ue_context_p->ue_context.Srb2.Srb_info.Srb_id; + + /* Is it the first income from S1AP ? */ if (ue_context_p->ue_context.eNB_ue_s1ap_id == 0) { ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; From 93a244cfaf970bcca06321bc0986cc73db3bf68c Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Mon, 2 Jan 2017 23:39:35 +0100 Subject: [PATCH 43/59] debugging for 20 MHz RRU --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 ++ openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf | 2 +- targets/RT/USER/lte-enb.c | 9 +++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 04982a19e6..4d3456b2ae 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -266,6 +266,8 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t } } else if (*packet_type == IF4p5_PRACH) { + if (eNB->CC_id==1) LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe); + // FIX: hard coded prach samples length db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 319ee8f48a..7252584756 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2813,7 +2813,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB){ LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - int offset = eNB->CC_id;//(eNB->single_thread_flag==1) ? 0 : (subframe&1); + int offset = (eNB->single_thread_flag==0) ? 0 : (subframe&1); if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf index 54c34520dd..e52a36542f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2680000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 100; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index c30e726609..30239c6608 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -421,7 +421,7 @@ void proc_tx_high0(PHY_VARS_eNB *eNB, relaying_type_t r_type, PHY_VARS_RN *rn) { - int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); @@ -1013,10 +1013,8 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; if (packet_type == IF4p5_PULFFT) { LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); - proc->subframe_rx = sf; - proc->frame_rx = f; - proc->symbol_mask[proc->subframe_rx] = proc->symbol_mask[proc->subframe_rx] | (1<symbol_mask[sf] = proc->symbol_mask[sf] | (1<CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]); } while(proc->symbol_mask[*subframe] != symbol_mask_full); + proc->subframe_rx = *subframe; + proc->frame_rx = *frame; + proc->symbol_mask[*subframe] = 0; proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event From 1d331c0bf8e9f7c0162d130d44ffb747f816fce2 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 3 Jan 2017 07:46:36 +0100 Subject: [PATCH 44/59] Changes for 20 MHz RRU (dual-thread mode) --- openair1/PHY/INIT/lte_init.c | 44 ++++--- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 14 +- openair1/PHY/LTE_TRANSPORT/pcfich.c | 2 +- openair1/PHY/MODULATION/slot_fep_ul.c | 14 +- openair1/PHY/defs.h | 2 +- openair1/SCHED/defs.h | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 25 ++-- targets/ARCH/COMMON/common_lib.h | 4 +- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 5 +- .../rru.band7.tm1.if4p5.100PRB.usrpb210.conf | 2 +- targets/RT/USER/lte-enb.c | 28 ++-- targets/RT/USER/lte-softmodem.c | 36 ++--- targets/RT/USER/rru_if4p5_usrp.gtkw | 124 +----------------- targets/SIMU/USER/init_lte.c | 54 ++++---- targets/SIMU/USER/init_lte.h | 1 + 15 files changed, 142 insertions(+), 215 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 3fb1d0c26b..2f023f8235 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -29,7 +29,7 @@ #include "LAYER2/MAC/extern.h" #include "MBSFN-SubframeConfigList.h" #include "UTIL/LOG/vcd_signal_dumper.h" -//#define DEBUG_PHY +#define DEBUG_PHY #include "assertions.h" #include @@ -1219,13 +1219,22 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, for (i=0; inb_antennas_tx; i++) { if (eNB->node_function != NGFI_RCC_IF4p5) + // Allocate 10 subframes of I/Q TX signal data (time) if not common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); + if (eNB->node_function == NGFI_RRU_IF4p5) + // Allocate 2 subframes of I/Q signal data (frequency) + common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*2*sizeof(int32_t) ); + else if (eNB->node_function != NGFI_RRU_IF5) + // Allocate 10 subframes of I/Q signal data (frequency) + common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); + #ifdef DEBUG_PHY - printf("[openair][LTE_PHY][INIT] common_vars->txdata[%d][%d] = %p\n",eNB_id,i,common_vars->txdata[eNB_id][i]); - printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%d bytes)\n", - eNB_id,i,common_vars->txdataF[eNB_id][i], - fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t)); + printf("[openair][LTE_PHY][INIT] common_vars->txdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->txdata[eNB_id][i], + fp->samples_per_tti*10*sizeof(int32_t)); + if (eNB->node_function != NGFI_RRU_IF5) + printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%lu bytes)\n", + eNB_id,i,common_vars->txdataF[eNB_id][i], + fp->ofdm_symbol_size*fp->symbols_per_tti*(eNB->node_function==NGFI_RRU_IF4p5?2:10)*sizeof(int32_t)); #endif } @@ -1238,18 +1247,23 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, for (i=0; inb_antennas_rx; i++) { if (eNB->node_function != NGFI_RCC_IF4p5) { + // allocate 2 subframes of I/Q signal data (time) if not an RCC (no time-domain signals) common_vars->rxdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - common_vars->rxdata_7_5kHz[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*sizeof(int32_t) ); + if (eNB->node_function != NGFI_RRU_IF5) + // allocate 2 subframes of I/Q signal data (time, 7.5 kHz offset) + common_vars->rxdata_7_5kHz[eNB_id][i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) ); } - - common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(fp->ofdm_symbol_size*fp->symbols_per_tti) ); + if (eNB->node_function != NGFI_RRU_IF5) + // allocate 2 subframes of I/Q signal data (frequency) + common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) ); #ifdef DEBUG_PHY - printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p\n",eNB_id,i,common_vars->rxdata[eNB_id][i]); - printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i]); + printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t)); + if (eNB->node_function != NGFI_RRU_IF5) + printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t)); #endif } - if (eNB->node_function != NGFI_RRU_IF4p5) { + if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) { // Channel estimates for SRS for (UE_id=0; UE_idnode_function != NGFI_RRU_IF4p5) { + if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) { generate_ul_ref_sigs_rx(); // SRS @@ -1286,7 +1300,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, // ULSCH VARS, skip if NFGI_RRU_IF4 - if (eNB->node_function!=NGFI_RRU_IF4p5) + if ((eNB->node_function!=NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) prach_vars->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int16_t) ); /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */ @@ -1299,7 +1313,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, #endif } - if (eNB->node_function != NGFI_RRU_IF4p5) { + if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) { AssertFatal(fp->nb_antennas_rx <= sizeof(prach_vars->prach_ifft) / sizeof(prach_vars->prach_ifft[0]), "nb_antennas_rx too large"); for (i=0; inb_antennas_rx; i++) { diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 04982a19e6..93f6e121cb 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -43,7 +43,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type int32_t **txdataF = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0]; int32_t **rxdataF = eNB->common_vars.rxdataF[0]; int16_t **rxsigF = eNB->prach_vars.rxsigF; - void *tx_buffer = eNB->ifbuffer.tx; + void *tx_buffer = eNB->ifbuffer.tx[subframe&1]; void *tx_buffer_prach = eNB->ifbuffer.tx_prach; uint16_t symbol_id=0, element_id=0; @@ -234,7 +234,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t LOG_D(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); - slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; + slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + ((*subframe)&1)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; for (element_id=0; element_idifdevice.priv); + int i; + if (eth->flags == ETH_RAW_IF4p5_MODE) { - eNB->ifbuffer.tx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + for (i=0;i<10;i++) + eNB->ifbuffer.tx[i] = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); eNB->ifbuffer.tx_prach = 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); + } else { + for (i=0;i<10;i++) + eNB->ifbuffer.tx[i] = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); eNB->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); eNB->ifbuffer.rx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); } diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c index 8af540eea1..f7e4fe58b5 100644 --- a/openair1/PHY/LTE_TRANSPORT/pcfich.c +++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c @@ -191,7 +191,7 @@ void generate_pcfich(uint8_t num_pdcch_symbols, // mapping nsymb = (frame_parms->Ncp==0) ? 14:12; - symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*((subframe*nsymb)); + symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(subframe*nsymb); re_offset = frame_parms->first_carrier_offset; // loop over 4 quadruplets and lookup REGs diff --git a/openair1/PHY/MODULATION/slot_fep_ul.c b/openair1/PHY/MODULATION/slot_fep_ul.c index b079896580..e05f5361de 100644 --- a/openair1/PHY/MODULATION/slot_fep_ul.c +++ b/openair1/PHY/MODULATION/slot_fep_ul.c @@ -79,10 +79,10 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms, if (no_prefix) { // subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1); - slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_tti>>1) * (Ns%2); + slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_tti>>1) * (Ns&1); } else { // subframe_offset = frame_parms->samples_per_tti * (Ns>>1); - slot_offset = (frame_parms->samples_per_tti>>1) * (Ns%2); + slot_offset = (frame_parms->samples_per_tti>>1) * (Ns&1); } if (l<0 || l>=7-frame_parms->Ncp) { @@ -108,18 +108,22 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms, 1 ); } else { + rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l; + /* should never happen for eNB if(rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) { memcpy((void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][frame_length_samples], (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][0], frame_parms->ofdm_symbol_size*sizeof(int)); } + */ - if( (rx_offset & 7) != 0){ + // check for 256-bit alignment of input buffer and do DFT directly, else do via intermediate buffer + if( (rx_offset & 15) != 0){ memcpy((void *)&tmp_dft_in, - (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][(rx_offset % frame_length_samples)], - frame_parms->ofdm_symbol_size*sizeof(int)); + (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][(rx_offset % frame_length_samples)], + frame_parms->ofdm_symbol_size*sizeof(int)); dft( (short *) tmp_dft_in, (short*) &eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol], 1 diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 66ff465708..7922fb131e 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -437,7 +437,7 @@ typedef struct PHY_VARS_eNB_s { // indicator for master/slave (RRU) int is_slave; void (*do_prach)(struct PHY_VARS_eNB_s *eNB,int frame,int subframe); - void (*fep)(struct PHY_VARS_eNB_s *eNB); + void (*fep)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc); int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *); void (*proc_uespec_rx)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type); diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index ba5f4cc8b5..2a502f923a 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -177,7 +177,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *pr @param phy_vars_eNB Pointer to eNB variables on which to act @param abstraction_flag Indicator of PHY abstraction */ -void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB); +void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); /*! \brief Scheduling for eNB TX procedures in TDD S-subframes. @param phy_vars_eNB Pointer to eNB variables on which to act diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 5e0c750b10..89ae2304e3 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2623,7 +2623,7 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) { } -void eNB_fep_full_2thread(PHY_VARS_eNB *eNB) { +void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) { eNB_proc_t *proc = &eNB->proc; @@ -2669,28 +2669,27 @@ void eNB_fep_full_2thread(PHY_VARS_eNB *eNB) { -void eNB_fep_full(PHY_VARS_eNB *eNB) { +void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) { - eNB_proc_t *proc = &eNB->proc; int l; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1); start_meas(&eNB->ofdm_demod_stats); - remove_7_5_kHz(eNB,proc->subframe_rx<<1); - remove_7_5_kHz(eNB,1+(proc->subframe_rx<<1)); + remove_7_5_kHz(eNB,proc_rxtx->subframe_rx<<1); + remove_7_5_kHz(eNB,1+(proc_rxtx->subframe_rx<<1)); for (l=0; lsymbols_per_tti/2; l++) { slot_fep_ul(fp, &eNB->common_vars, l, - proc->subframe_rx<<1, + (proc_rxtx->subframe_rx)<<1, 0, 0 ); slot_fep_ul(fp, &eNB->common_vars, l, - 1+(proc->subframe_rx<<1), + 1+((proc_rxtx->subframe_rx)<<1), 0, 0 ); @@ -2701,11 +2700,11 @@ void eNB_fep_full(PHY_VARS_eNB *eNB) { if (eNB->node_function == NGFI_RRU_IF4p5) { /// **** send_IF4 of rxdataF to RCC (no prach now) **** /// - send_IF4p5(eNB, proc->frame_rx, proc->subframe_rx, IF4p5_PULFFT, 0); + send_IF4p5(eNB, proc_rxtx->frame_rx, proc_rxtx->subframe_rx, IF4p5_PULFFT, 0); } } -void eNB_fep_rru_if5(PHY_VARS_eNB *eNB) { +void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) { eNB_proc_t *proc=&eNB->proc; uint8_t seqno=0; @@ -2759,14 +2758,14 @@ void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe) { } -void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB){ +void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){ - eNB_proc_t *proc = &eNB->proc; + // eNB_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - int offset = eNB->CC_id;//(eNB->single_thread_flag==1) ? 0 : (subframe&1); + int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1); if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; @@ -2778,7 +2777,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB){ LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_common_RX(%d)\n",eNB->Mod_id,frame,subframe); - if (eNB->fep) eNB->fep(eNB); + if (eNB->fep) eNB->fep(eNB,proc); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON+offset, 0 ); } diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 79993dc52c..98f383cb61 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -247,8 +247,8 @@ typedef struct { typedef struct { - //! Tx buffer for if device - void *tx; + //! Tx buffer for if device, keep one per subframe now to allow multithreading + void *tx[10]; //! Tx buffer (PRACH) for if device void *tx_prach; //! Rx buffer for if device diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index a12e374e8a..3d0674c73e 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -759,7 +759,10 @@ extern "C" { // create tx & rx streamer uhd::stream_args_t stream_args_rx("sc16", "sc16"); - //stream_args_rx.args["spp"] = str(boost::format("%d") % 2048);//(openair0_cfg[0].rx_num_channels*openair0_cfg[0].samples_per_packet)); + int samples=openair0_cfg[0].sample_rate; + samples/=24000; + // stream_args_rx.args["spp"] = str(boost::format("%d") % samples); + for (i = 0; irx_stream = s->usrp->get_rx_stream(stream_args_rx); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf index 664bbec846..aa731c8d8a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.100PRB.usrpb210.conf @@ -159,7 +159,7 @@ eNBs = rrh_gw_config = ( { local_if_name = "eth0"; - remote_address = "10.10.10.155"; + remote_address = "10.10.10.215"; local_address = "10.10.10.60"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index eccb09758c..49f820a8b4 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -286,7 +286,8 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); - slot_offset_F = (subframe<<1)*slot_sizeF; + // compute subframe modulo-2 + slot_offset_F = ((subframe&1)<<1)*slot_sizeF; slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti; @@ -554,7 +555,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if ((eNB->do_prach)&&((eNB->node_function != NGFI_RCC_IF4p5))) eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx); - phy_procedures_eNB_common_RX(eNB); + phy_procedures_eNB_common_RX(eNB,proc); // UE-specific RX processing for subframe n if (eNB->proc_uespec_rx) eNB->proc_uespec_rx(eNB, proc, no_relay ); @@ -864,7 +865,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { unsigned int rxs,txs; int i; int tx_sfoffset = 3;//(eNB->single_thread_flag == 1) ? 3 : 3; - openair0_timestamp old_ts; + openair0_timestamp ts,old_ts; if (proc->first_rx==0) { @@ -878,7 +879,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, - proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, + proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, txp, fp->samples_per_tti, fp->nb_antennas_tx, @@ -902,26 +903,32 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { old_ts = proc->timestamp_rx; rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &(proc->timestamp_rx), + &ts, rxp, fp->samples_per_tti, fp->nb_antennas_rx); + proc->timestamp_rx = ts-eNB->ts_offset; + if (rxs != fp->samples_per_tti) LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - if (proc->first_rx == 1) + if (proc->first_rx == 1) { eNB->ts_offset = proc->timestamp_rx; + proc->timestamp_rx=0; + } else { + if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts - fp->samples_per_tti); eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); + proc->timestamp_rx = ts-eNB->ts_offset; } } - proc->frame_rx = ((proc->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = ((proc->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; proc->frame_rx = (proc->frame_rx+proc->frame_offset)&1023; proc->frame_tx = proc->frame_rx; if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023; @@ -1860,8 +1867,8 @@ int start_rf(PHY_VARS_eNB *eNB) { } extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB); -extern void eNB_fep_full(PHY_VARS_eNB *eNB); -extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB); +extern void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); +extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); extern void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe); void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *eth_params,int single_thread_flag,int wait_for_sync) { @@ -1933,6 +1940,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst } eNB->rfdevice.host_type = RRH_HOST; eNB->ifdevice.host_type = RRH_HOST; + printf("loading transport interface ...\n"); ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); if (ret<0) { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index d7a4407904..453b5934d6 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1622,35 +1622,34 @@ int main( int argc, char **argv ) PHY_vars_eNB_g[0] = malloc(sizeof(PHY_VARS_eNB*)); for (CC_id=0; CC_idNid_cell,abstraction_flag); - PHY_vars_eNB_g[0][CC_id]->CC_id = CC_id; - + PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,node_function[CC_id],abstraction_flag); PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff; PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs; PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6; PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs; - + if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; - + if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode for (i=0; ipusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; - - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; + + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; } } - + compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, - PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, - PHY_vars_eNB_g[0][CC_id]->X_u); - + PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, + PHY_vars_eNB_g[0][CC_id]->X_u); + + PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; - + if (frame_parms[CC_id]->frame_type==FDD) { PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; } @@ -1663,7 +1662,7 @@ int main( int argc, char **argv ) PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; } } - + NB_eNB_INST=1; NB_INST=1; @@ -1843,6 +1842,7 @@ int main( int argc, char **argv ) } } else { + printf("Initializing eNB threads\n"); init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync); number_of_cards = 1; diff --git a/targets/RT/USER/rru_if4p5_usrp.gtkw b/targets/RT/USER/rru_if4p5_usrp.gtkw index df8de754db..62744addfe 100644 --- a/targets/RT/USER/rru_if4p5_usrp.gtkw +++ b/targets/RT/USER/rru_if4p5_usrp.gtkw @@ -1,12 +1,12 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Mon Aug 1 18:43:22 2016 +[*] Tue Jan 3 00:00:25 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Mon Aug 1 18:41:49 2016" -[dumpfile_size] 22622 -[savefile] "/home/papillon/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw" -[timestart] 0 +[dumpfile_mtime] "Mon Jan 2 23:59:11 2017" +[dumpfile_size] 93728 +[savefile] "/home/uprru1/oai/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw" +[timestart] 23491157000 [size] 1301 716 [pos] 309 0 *-19.793451 29983948856 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 @@ -20,7 +20,6 @@ functions.trx_write functions.trx_write_if functions.send_if4 functions.trx_read_if -@29 functions.recv_if4 @24 variables.trx_ts[63:0] @@ -43,118 +42,5 @@ variables.subframe_number_TX1_eNB[63:0] functions.phy_enb_sfgen functions.phy_eNB_slot_fep functions.phy_enb_prach_rx -@24 -variables.dci_info[63:0] -variables.ue0_BO[63:0] -@420 -variables.ue0_BSR[63:0] -variables.ue0_timing_advance[63:0] -@28 -functions.macxface_initiate_ra_proc -functions.macxface_terminate_ra_proc -functions.phy_enb_ulsch_msg3 -functions.macxface_SR_indication -@420 -variables.ue0_SR_ENERGY[63:0] -variables.ue0_SR_THRES[63:0] -@28 -functions.phy_enb_ulsch_decoding0 -@24 -variables.ue0_res0[63:0] -@420 -variables.ue0_rssi0[63:0] -variables.ue0_MCS0[63:0] -variables.ue0_RB0[63:0] -@24 -variables.ue0_ROUND0[63:0] -variables.ue0_SFN0[63:0] -@28 -functions.phy_enb_ulsch_decoding1 -@24 -variables.ue0_res1[63:0] -@420 -variables.ue0_rssi1[63:0] -variables.ue0_MCS1[63:0] -variables.ue0_RB1[63:0] -@24 -variables.ue0_ROUND1[63:0] -variables.ue0_SFN1[63:0] -@28 -functions.phy_enb_ulsch_decoding2 -@24 -variables.ue0_res2[63:0] -@420 -variables.ue0_rssi2[63:0] -variables.ue0_MCS2[63:0] -variables.ue0_RB2[63:0] -@24 -variables.ue0_ROUND2[63:0] -variables.ue0_SFN2[63:0] -@28 -functions.phy_enb_ulsch_decoding3 -@24 -variables.ue0_res3[63:0] -@420 -variables.ue0_rssi3[63:0] -variables.ue0_MCS3[63:0] -variables.ue0_RB3[63:0] -@24 -variables.ue0_ROUND3[63:0] -variables.ue0_SFN3[63:0] -@28 -functions.phy_enb_ulsch_decoding4 -@420 -variables.ue0_rssi4[63:0] -@24 -variables.ue0_res4[63:0] -@420 -variables.ue0_MCS4[63:0] -variables.ue0_RB4[63:0] -@24 -variables.ue0_ROUND4[63:0] -variables.ue0_SFN4[63:0] -@28 -functions.phy_enb_ulsch_decoding5 -@24 -variables.ue0_res5[63:0] -@420 -variables.ue0_rssi5[63:0] -variables.ue0_MCS5[63:0] -variables.ue0_RB5[63:0] -@24 -variables.ue0_ROUND5[63:0] -variables.ue0_SFN5[63:0] -@28 -functions.phy_enb_ulsch_decoding6 -@24 -variables.ue0_res6[63:0] -@420 -variables.ue0_rssi6[63:0] -variables.ue0_MCS6[63:0] -variables.ue0_RB6[63:0] -@24 -variables.ue0_ROUND6[63:0] -variables.ue0_SFN6[63:0] -@28 -functions.phy_enb_ulsch_decoding7 -@24 -variables.ue0_res7[63:0] -@420 -variables.ue0_rssi7[63:0] -variables.ue0_MCS7[63:0] -variables.ue0_RB7[63:0] -@24 -variables.ue0_ROUND7[63:0] -variables.ue0_SFN7[63:0] -@28 -functions.phy_enb_prach_rx -functions.phy_eNB_dlsch_encoding -functions.phy_eNB_dlsch_modulation -functions.phy_eNB_dlsch_scrambling -functions.phy_enb_pdcch_tx -functions.phy_enb_rs_tx -functions.rrc_mac_config_req -functions.rlc_data_req -functions.udp_enb_task [pattern_trace] 1 [pattern_trace] 0 diff --git a/targets/SIMU/USER/init_lte.c b/targets/SIMU/USER/init_lte.c index 5a742e9e61..7071702c28 100644 --- a/targets/SIMU/USER/init_lte.c +++ b/targets/SIMU/USER/init_lte.c @@ -41,6 +41,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, uint8_t Nid_cell, + eNB_func_t node_function, uint8_t abstraction_flag) { @@ -54,6 +55,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, PHY_vars_eNB->frame_parms.nushift = PHY_vars_eNB->frame_parms.Nid_cell%6; phy_init_lte_eNB(PHY_vars_eNB,0,abstraction_flag); + LOG_I(PHY,"init eNB: Node Function %d\n",node_function); LOG_I(PHY,"init eNB: Nid_cell %d\n", frame_parms->Nid_cell); LOG_I(PHY,"init eNB: frame_type %d,tdd_config %d\n", frame_parms->frame_type,frame_parms->tdd_config); LOG_I(PHY,"init eNB: number of ue max %d number of enb max %d number of harq pid max %d\n", @@ -61,27 +63,33 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, LOG_I(PHY,"init eNB: N_RB_DL %d\n", frame_parms->N_RB_DL); LOG_I(PHY,"init eNB: prach_config_index %d\n", frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); + if (node_function >= NGFI_RRU_IF5) + // For RRU, don't allocate DLSCH/ULSCH Transport channel buffers + return (PHY_vars_eNB); + for (i=0; idlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL,abstraction_flag); - + if (!PHY_vars_eNB->dlsch[i][j]) { - LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); - exit(-1); + LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); + exit(-1); } else { - LOG_D(PHY,"dlsch[%d][%d] => %p\n",i,j,PHY_vars_eNB->dlsch[i][j]); - PHY_vars_eNB->dlsch[i][j]->rnti=0; + LOG_D(PHY,"dlsch[%d][%d] => %p\n",i,j,PHY_vars_eNB->dlsch[i][j]); + PHY_vars_eNB->dlsch[i][j]->rnti=0; } } - + + LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n"); PHY_vars_eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,frame_parms->N_RB_UL, abstraction_flag); - + if (!PHY_vars_eNB->ulsch[1+i]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } - + // this is the transmission mode for the signalling channels // this will be overwritten with the real transmission mode by the RRC once the UE is connected PHY_vars_eNB->transmission_mode[i] = frame_parms->nb_antennas_tx_eNB==1 ? 1 : 2; @@ -91,7 +99,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, gettimeofday(&ts, NULL); PHY_vars_eNB->ulsch[1+i]->reference_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; int j; - + for (j=0; j<10; j++) { initialize(&PHY_vars_eNB->ulsch[1+i]->loc_rss_list[j]); initialize(&PHY_vars_eNB->ulsch[1+i]->loc_rssi_list[j]); @@ -99,7 +107,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, initialize(&PHY_vars_eNB->ulsch[1+i]->loc_timing_advance_list[j]); initialize(&PHY_vars_eNB->ulsch[1+i]->loc_timing_update_list[j]); } - + initialize(&PHY_vars_eNB->ulsch[1+i]->tot_loc_rss_list); initialize(&PHY_vars_eNB->ulsch[1+i]->tot_loc_rssi_list); initialize(&PHY_vars_eNB->ulsch[1+i]->tot_loc_subcarrier_rss_list); @@ -107,37 +115,37 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, initialize(&PHY_vars_eNB->ulsch[1+i]->tot_loc_timing_update_list); #endif } - + // ULSCH for RA PHY_vars_eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, frame_parms->N_RB_UL, abstraction_flag); - + if (!PHY_vars_eNB->ulsch[0]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } - + PHY_vars_eNB->dlsch_SI = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL, abstraction_flag); LOG_D(PHY,"eNB %d : SI %p\n",eNB_id,PHY_vars_eNB->dlsch_SI); PHY_vars_eNB->dlsch_ra = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL, abstraction_flag); LOG_D(PHY,"eNB %d : RA %p\n",eNB_id,PHY_vars_eNB->dlsch_ra); PHY_vars_eNB->dlsch_MCH = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL, 0); LOG_D(PHY,"eNB %d : MCH %p\n",eNB_id,PHY_vars_eNB->dlsch_MCH); - - + + PHY_vars_eNB->rx_total_gain_dB=130; - + for(i=0; imu_mimo_mode[i].dl_pow_off = 2; - + PHY_vars_eNB->check_for_total_transmissions = 0; - + PHY_vars_eNB->check_for_MUMIMO_transmissions = 0; - + PHY_vars_eNB->FULL_MUMIMO_transmissions = 0; - + PHY_vars_eNB->check_for_SUMIMO_transmissions = 0; - - PHY_vars_eNB->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; + + PHY_vars_eNB->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; return (PHY_vars_eNB); } @@ -271,7 +279,7 @@ void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs], PHY_vars_eNB_g[eNB_id] = (PHY_VARS_eNB**) malloc(MAX_NUM_CCs*sizeof(PHY_VARS_eNB*)); for (CC_id=0; CC_idMod_id=eNB_id; PHY_vars_eNB_g[eNB_id][CC_id]->CC_id=CC_id; } diff --git a/targets/SIMU/USER/init_lte.h b/targets/SIMU/USER/init_lte.h index bcb2570565..e49c24a15b 100644 --- a/targets/SIMU/USER/init_lte.h +++ b/targets/SIMU/USER/init_lte.h @@ -25,6 +25,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, uint8_t Nid_cell, + eNB_func_t node_function, uint8_t abstraction_flag); PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms, From e66338669e04a3b54d3b786bcd0b0bdfd4e4b7dd Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Jan 2017 09:47:14 +0100 Subject: [PATCH 45/59] changes for RRU (merge with develop). single-thread-disable flag is functional for RRU. --- openair1/PHY/INIT/lte_init.c | 25 ++++++++----------------- openair1/PHY/MODULATION/ofdm_mod.c | 20 ++++++++++---------- openair1/SIMULATION/LTE_PHY/dlsim.c | 11 +++++++++-- targets/RT/USER/lte-enb.c | 2 +- targets/RT/USER/rru_if4p5_usrp.gtkw | 8 ++++---- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index db3c8d6b72..5176f9ee6c 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1304,35 +1304,26 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, common_vars->txdataF[eNB_id] = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t*)); common_vars->txdataF_BF[eNB_id] = (int32_t **)malloc16(fp->nb_antennas_tx*sizeof(int32_t*)); - for (i=0; i<14; i++) { - common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); + if (eNB->node_function != NGFI_RRU_IF5) { + for (i=0; i<((eNB->do_precoding==0)?fp->nb_antennas_tx:14); i++) { + common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); #ifdef DEBUG_PHY - msg("[openair][LTE_PHY][INIT] lte_common_vars->txdataF[%d][%d] = %p (%d bytes)\n", - eNB_id,i,common_vars->txdataF[eNB_id][i], - fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t)); + printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%lu bytes)\n", + eNB_id,i,common_vars->txdataF[eNB_id][i], + fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t)); #endif + } } - for (i=0; inb_antennas_tx; i++) { common_vars->txdataF_BF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t) ); if (eNB->node_function != NGFI_RCC_IF4p5) // Allocate 10 subframes of I/Q TX signal data (time) if not common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - if (eNB->node_function == NGFI_RRU_IF4p5) - // Allocate 2 subframes of I/Q signal data (frequency) - common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*2*sizeof(int32_t) ); - else if (eNB->node_function != NGFI_RRU_IF5) - // Allocate 10 subframes of I/Q signal data (frequency) - common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); #ifdef DEBUG_PHY printf("[openair][LTE_PHY][INIT] common_vars->txdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->txdata[eNB_id][i], fp->samples_per_tti*10*sizeof(int32_t)); - if (eNB->node_function != NGFI_RRU_IF5) - printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%lu bytes)\n", - eNB_id,i,common_vars->txdataF[eNB_id][i], - fp->ofdm_symbol_size*fp->symbols_per_tti*(eNB->node_function==NGFI_RRU_IF4p5?2:10)*sizeof(int32_t)); #endif } @@ -1379,7 +1370,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, // allocate 2 subframes of I/Q signal data (frequency) common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) ); #ifdef DEBUG_PHY - printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t)); + printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata[eNB_id][i],fp->samples_per_tti*10*sizeof(int32_t)); if (eNB->node_function != NGFI_RRU_IF5) printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t)); #endif diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 953e130115..8e09cea1ec 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -288,13 +288,13 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding) { - int aa, l, slot_offset; - int32_t **txdataF = eNB_common_vars->txdataF[eNB_id]; - int32_t **txdataF_BF = (do_precoding==1)?eNB_common_vars->txdataF_BF[eNB_id]:txdataF; - int32_t **txdata = eNB_common_vars->txdata[eNB_id]; - - slot_offset = (next_slot)*(frame_parms->samples_per_tti>>1); + int aa, l, slot_offset, slot_offsetF; + int32_t **txdataF = eNB_common_vars->txdataF[eNB_id]; + int32_t **txdataF_BF = eNB_common_vars->txdataF_BF[eNB_id]; + int32_t **txdata = eNB_common_vars->txdata[eNB_id]; + slot_offset = (next_slot)*(frame_parms->samples_per_tti>>1); + slot_offsetF = (next_slot)*(frame_parms->ofdm_symbol_size)*((frame_parms->Ncp==EXTENDED) ? 6 : 7); //printf("Thread %d starting ... aa %d (%llu)\n",omp_get_thread_num(),aa,rdtsc()); for (l=0; lsymbols_per_tti>>1; l++) { @@ -307,8 +307,8 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne //PMCH case not implemented... - if (frame_parms->Ncp == 1) - PHY_ofdm_mod(txdataF_BF[aa], // input + if (frame_parms->Ncp == EXTENDED) + PHY_ofdm_mod((do_precoding == 1)?txdataF_BF[aa]:&txdataF[aa][slot_offsetF+l*frame_parms->ofdm_symbol_size], // input &txdata[aa][slot_offset+l*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES], // output frame_parms->ofdm_symbol_size, 1, // number of symbols @@ -316,7 +316,7 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne CYCLIC_PREFIX); else { if (l==0) { - PHY_ofdm_mod(txdataF_BF[aa], // input + PHY_ofdm_mod((do_precoding==1)?txdataF_BF[aa]:&txdataF[aa][slot_offsetF+l*frame_parms->ofdm_symbol_size], // input &txdata[aa][slot_offset], // output frame_parms->ofdm_symbol_size, 1, // number of symbols @@ -324,7 +324,7 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne CYCLIC_PREFIX); } else { - PHY_ofdm_mod(txdataF_BF[aa], // input + PHY_ofdm_mod((do_precoding==1)?txdataF_BF[aa]:&txdataF[aa][slot_offsetF+l*frame_parms->ofdm_symbol_size], // input &txdata[aa][slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES], // output frame_parms->ofdm_symbol_size, 1, // number of symbols diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index f9a8acfa85..879573525a 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -1812,6 +1812,11 @@ int main(int argc, char **argv) eNB->common_vars.beam_weights[0][0][aa][re] = 0x00007fff/eNB->frame_parms.nb_antennas_tx; } + if (transmission_mode<7) + eNB->do_precoding=0; + else + eNB->do_precoding=1; + eNB->mac_enabled=1; if (two_thread_flag == 0) { eNB->te = dlsch_encoding; @@ -2409,12 +2414,14 @@ int main(int argc, char **argv) do_OFDM_mod_symbol(&eNB->common_vars, eNB_id, (subframe*2), - &eNB->frame_parms); + &eNB->frame_parms, + eNB->do_precoding); do_OFDM_mod_symbol(&eNB->common_vars, eNB_id, (subframe*2)+1, - &eNB->frame_parms); + &eNB->frame_parms, + eNB->do_precoding); stop_meas(&eNB->ofdm_mod_stats); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 9f330a1be6..2b8eecc505 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -867,7 +867,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; unsigned int rxs,txs; int i; - int tx_sfoffset = 3;//(eNB->single_thread_flag == 1) ? 3 : 3; + int tx_sfoffset = (eNB->single_thread_flag == 1) ? 3 : 2; openair0_timestamp ts,old_ts; if (proc->first_rx==0) { diff --git a/targets/RT/USER/rru_if4p5_usrp.gtkw b/targets/RT/USER/rru_if4p5_usrp.gtkw index 62744addfe..d2a435202f 100644 --- a/targets/RT/USER/rru_if4p5_usrp.gtkw +++ b/targets/RT/USER/rru_if4p5_usrp.gtkw @@ -1,10 +1,10 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Tue Jan 3 00:00:25 2017 +[*] Thu Jan 5 06:19:58 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Mon Jan 2 23:59:11 2017" -[dumpfile_size] 93728 +[dumpfile_mtime] "Thu Jan 5 06:09:13 2017" +[dumpfile_size] 24570356 [savefile] "/home/uprru1/oai/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw" [timestart] 23491157000 [size] 1301 716 @@ -39,7 +39,7 @@ variables.subframe_number_RX1_eNB[63:0] variables.frame_number_TX1_eNB[63:0] variables.subframe_number_TX1_eNB[63:0] @28 -functions.phy_enb_sfgen +functions.phy_eNB_ofdm_mod_l functions.phy_eNB_slot_fep functions.phy_enb_prach_rx [pattern_trace] 1 From 328731af18a15304f6b2c9552eb08308f194895e Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 6 Jan 2017 20:26:42 +0100 Subject: [PATCH 46/59] band7 rcc configuration --- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf index 4b62f83320..886d88eab1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2680000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; From 0e919b9913ddc228c0596d8955125b01686d982d Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 7 Jan 2017 04:28:06 +0100 Subject: [PATCH 47/59] configuration file band7 rru --- .../CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf index ecbe2f049f..d40b901785 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.usrpb210.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; From 14d28e2dbd25cd8a1614fe97d8bebe788cea56ec Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sat, 7 Jan 2017 12:41:36 +0100 Subject: [PATCH 48/59] fixes for precoding (turning off if nb_antennas_tx=1), configuration files, timing advance with 3/4 sampling on 20 MHz, logging in MAC --- openair1/PHY/LTE_TRANSPORT/prach.c | 9 ++++-- openair1/PHY/MODULATION/beamforming.c | 27 ++++++++-------- openair1/SCHED/phy_procedures_lte_eNb.c | 11 ++++--- openair2/LAYER2/MAC/eNB_scheduler.c | 5 +-- openair2/LAYER2/MAC/pre_processor.c | 5 ++- .../CONF/enb.band7.tm1.100PRB.usrpb210.conf | 6 ++-- .../CONF/enb.band7.tm1.50PRB.usrpb210.conf | 4 +-- .../CONF/rcc.band7.tm1.if4p5.25PRB.conf | 2 +- .../CONF/rcc.band7.tm1.if4p5.50PRB.conf | 2 +- targets/RT/USER/lte-enb.c | 32 +++++++++---------- 10 files changed, 57 insertions(+), 46 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 33780a7def..489fdb0f71 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -1185,9 +1185,7 @@ void rx_prach(PHY_VARS_eNB *eNB, break; } - if (eNB->frame_parms.threequarter_fs == 1) - Ncp=(Ncp*3)>>2; - + // Adjust CP length based on UL bandwidth switch (eNB->frame_parms.N_RB_UL) { case 6: Ncp>>=4; @@ -1208,6 +1206,11 @@ void rx_prach(PHY_VARS_eNB *eNB, case 75: Ncp=(Ncp*3)>>2; break; + + case 100: + if (eNB->frame_parms.threequarter_fs == 1) + Ncp=(Ncp*3)>>2; + break; } diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 6557a47ee7..4f2f7535e9 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -66,24 +66,25 @@ int beam_precoding(int32_t **txdataF, for (p=0; p<14; p++) { //if (p==0 || p==1 || p==5 || p>7) // mult_cpx_conj_vector((int16_t*)txdataF[p], (int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15); - for (re=0;reofdm_symbol_size;re++) { - if ((p==0 || p==1 || p==5 || p>=7) && txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) { + if (txdataF[p]) {//[slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) { + + for (re=0;reofdm_symbol_size;re++) { ((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15); ((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15); ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15); ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15); - - /* + + /* printf("beamforming.c:txdataF[%d][%d]=%d+j%d, beam_weights[%d][%d][%d]=%d+j%d,txdata_BF[%d][%d]=%d+j%d\n", - p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re, - ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0], - ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1], - p,aa,re, - ((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1], - aa,re, - ((int16_t*)&txdataF_BF[aa][re])[0], - ((int16_t*)&txdataF_BF[aa][re])[1]); - */ + p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re, + ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0], + ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1], + p,aa,re, + ((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1], + aa,re, + ((int16_t*)&txdataF_BF[aa][re])[0], + ((int16_t*)&txdataF_BF[aa][re])[1]); + */ } } } diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 85c822e273..50fd920262 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2032,8 +2032,8 @@ void prach_procedures(PHY_VARS_eNB *eNB) { T_INT(preamble_max), T_INT(preamble_energy_max), T_INT(preamble_delay_list[preamble_max])); if (eNB->mac_enabled==1) { - uint8_t update_TA=4; - + uint8_t update_TA = 4; + uint8_t update_TA2 = 1; switch (fp->N_RB_DL) { case 6: update_TA = 16; @@ -2047,8 +2047,11 @@ void prach_procedures(PHY_VARS_eNB *eNB) { update_TA = 2; break; + case 75: + update_TA = 3; + update_TA2 = 2; case 100: - update_TA = 1; + update_TA = 1; break; } @@ -2056,7 +2059,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) { eNB->CC_id, frame, preamble_max, - preamble_delay_list[preamble_max]*update_TA, + preamble_delay_list[preamble_max]*update_TA/update_TA2, 0,subframe,0); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index c5dc8c88b0..9a3a8f637e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -128,8 +128,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); if ((frameP==0)&&(subframeP==0)) - LOG_I(MAC,"UE rnti %x : %s\n", rnti, - UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync"); + LOG_I(MAC,"UE rnti %x : %s, PHR %d dB\n", rnti, + UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync", + UE_list->UE_template[CC_id][i].phr_info); next_i= UE_list->next[i]; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index ed12d322c1..5024aa605d 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -791,7 +791,10 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, break; case 100: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16; + if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.threequarter_fs == 0) + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16; + else + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12; break; } // clear the update in case PHY does not have a new measurement after timer expiry diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf index f4ed76a21e..c974345888 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2680000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 100; @@ -70,7 +70,7 @@ eNBs = pusch_p0_Nominal = -96; pusch_alpha = "AL1"; - pucch_p0_Nominal = -100; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -149,7 +149,7 @@ eNBs = ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; ENB_INTERFACE_NAME_FOR_S1U = "lo"; - ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index bcf1c15a4a..3cf1e7d15b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -31,7 +31,7 @@ eNBs = tdd_config_s = 0; prefix_type = "NORMAL"; eutra_band = 7; - downlink_frequency = 2660000000L; + downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; N_RB_DL = 50; @@ -149,7 +149,7 @@ eNBs = ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; ENB_INTERFACE_NAME_FOR_S1U = "lo"; - ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf index 5bdfcc7a12..f9ebec3ab5 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf @@ -150,7 +150,7 @@ eNBs = ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; ENB_INTERFACE_NAME_FOR_S1U = "lo"; - ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf index 886d88eab1..4ad5767ce9 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf @@ -151,7 +151,7 @@ eNBs = ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; ENB_INTERFACE_NAME_FOR_S1U = "lo"; - ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 99e05a39bf..8a01179567 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1964,7 +1964,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst break; case eNodeB_3GPP: - eNB->do_precoding = 1; + eNB->do_precoding = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1; eNB->do_prach = do_prach; eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; @@ -1985,27 +1985,27 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->ifdevice.host_type = BBU_HOST; break; case eNodeB_3GPP_BBU: - eNB->do_precoding = 1; - eNB->do_prach = do_prach; - eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; - eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_full; + eNB->do_precoding = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1; + eNB->do_prach = do_prach; + eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; + eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; + eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; + eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; + eNB->proc_tx = proc_tx_full; if (eNB->node_timing == synch_to_other) { - eNB->tx_fh = tx_fh_if5_mobipass; - eNB->rx_fh = rx_fh_slave; - eNB->fh_asynch = fh_if5_asynch_UL; + eNB->tx_fh = tx_fh_if5_mobipass; + eNB->rx_fh = rx_fh_slave; + eNB->fh_asynch = fh_if5_asynch_UL; } else { - eNB->tx_fh = tx_fh_if5; - eNB->rx_fh = rx_fh_if5; - eNB->fh_asynch = NULL; + eNB->tx_fh = tx_fh_if5; + eNB->rx_fh = rx_fh_if5; + eNB->fh_asynch = NULL; } - eNB->start_rf = NULL; - eNB->start_if = start_if; + eNB->start_rf = NULL; + eNB->start_if = start_if; eNB->rfdevice.host_type = BBU_HOST; eNB->ifdevice.host_type = BBU_HOST; From 5575fed27bf89352a47d9e16f0098011393b3f94 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sat, 7 Jan 2017 12:55:48 +0100 Subject: [PATCH 49/59] some warning removal. --- targets/RT/USER/lte-enb.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8a01179567..fb2271fa72 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -128,7 +128,7 @@ extern pthread_cond_t sync_cond; extern pthread_mutex_t sync_mutex; extern int sync_var; -extern transmission_mode; +extern int transmission_mode; //pthread_t main_eNB_thread; @@ -1010,7 +1010,7 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { uint16_t packet_type; uint32_t symbol_number=0; - uint32_t symbol_mask, symbol_mask_full; + uint32_t symbol_mask_full; symbol_mask_full = (1<symbols_per_tti)-1; @@ -1258,6 +1258,7 @@ void *eNB_thread_synch(void *arg) { lte_sync_time_free(); + return NULL; } int wakeup_synch(PHY_VARS_eNB *eNB){ @@ -1486,6 +1487,10 @@ static void* eNB_thread_single( void* param ) { rxp, fp->samples_per_tti*10, fp->nb_antennas_rx); + + if (rxs != (fp->samples_per_tti*10)) + exit_fun("Problem receiving samples\n"); + // wakeup synchronization processing thread wakeup_synch(eNB); ic=0; @@ -1502,6 +1507,9 @@ static void* eNB_thread_single( void* param ) { rxp2, fp->samples_per_tti, fp->nb_antennas_rx); + if (rxs != fp->samples_per_tti) + exit_fun( "problem receiving samples" ); + pthread_mutex_lock(&eNB->proc.mutex_synch); ic = eNB->proc.instance_cnt_synch; pthread_mutex_unlock(&eNB->proc.mutex_synch); @@ -1514,6 +1522,9 @@ static void* eNB_thread_single( void* param ) { rxp, eNB->rx_offset, fp->nb_antennas_rx); + if (rxs != eNB->rx_offset) + exit_fun( "problem receiving samples" ); + for (i=0;i<4;i++) { eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; @@ -1876,7 +1887,7 @@ int start_rf(PHY_VARS_eNB *eNB) { return(eNB->rfdevice.trx_start_func(&eNB->rfdevice)); } -extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB); +extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); extern void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); extern void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe); @@ -1964,7 +1975,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst break; case eNodeB_3GPP: - eNB->do_precoding = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1; + eNB->do_precoding = (eNB->frame_parms.nb_antennas_tx==1) ? 0 : 1; eNB->do_prach = do_prach; eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; @@ -1985,7 +1996,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->ifdevice.host_type = BBU_HOST; break; case eNodeB_3GPP_BBU: - eNB->do_precoding = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1; + eNB->do_precoding = (eNB->frame_parms.nb_antennas_tx==1) ? 0 : 1; eNB->do_prach = do_prach; eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; From 5715de89f2fb7a3f626f8e945d453e89e43fe64b Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 13 Jan 2017 14:17:26 +0100 Subject: [PATCH 50/59] changes for TDD fronthaul --- targets/RT/USER/lte-enb.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index fb2271fa72..f22e7a9ffa 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -406,16 +406,22 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) void tx_fh_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL); + if ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL); } void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); + if ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); } -void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); +void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { + if ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); } void proc_tx_high0(PHY_VARS_eNB *eNB, From 848f78465beb7eab74bb54450065edcb48bd711e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 13 Jan 2017 19:49:22 +0100 Subject: [PATCH 51/59] addition of IF4p5 ULTICK packet for TDD fronthaul --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 65 +++++++++++-------- openair1/PHY/LTE_TRANSPORT/if4_tools.h | 3 +- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c | 2 + targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c | 2 + targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h | 2 + targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 12 +++- targets/RT/USER/lte-enb.c | 44 +++++++------ 7 files changed, 82 insertions(+), 48 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 3ffc50efb9..6878ae2684 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -100,7 +100,8 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type slotoffsetF += fp->ofdm_symbol_size; blockoffsetF += fp->ofdm_symbol_size; } - } else if (packet_type == IF4p5_PULFFT) { + } else if ((packet_type == IF4p5_PULFFT)|| + (packet_type == IF4p5_PULTICK)){ db_fulllength = 12*fp->N_RB_UL; db_halflength = (db_fulllength)>>1; slotoffsetF = 1; @@ -113,33 +114,45 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type 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); + gen_IF4p5_ul_header(packet_header, packet_type, frame, subframe); - for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); - for (element_id=0; element_idframe_status &= ~(0x000f<<26); - packet_header->frame_status |= (symbol_id&0x000f)<<26; - + if (packet_type == IF4p5_PULFFT) { + for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { + LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); + for (element_id=0; element_idframe_status &= ~(0x000f<<26); + packet_header->frame_status |= (symbol_id&0x000f)<<26; + + if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice, + symbol_id, + &tx_buffer, + db_fulllength, + 1, + IF4p5_PULFFT)) < 0) { + perror("ETHERNET write for IF4p5_PULFFT\n"); + } + + slotoffsetF += fp->ofdm_symbol_size; + blockoffsetF += fp->ofdm_symbol_size; + } + } + else { if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice, - symbol_id, - &tx_buffer, - db_fulllength, + 0, + &tx_buffer, + 0, 1, - IF4p5_PULFFT)) < 0) { - perror("ETHERNET write for IF4p5_PULFFT\n"); + IF4p5_PULTICK)) < 0) { + perror("ETHERNET write for IF4p5_PULFFT\n"); } - - slotoffsetF += fp->ofdm_symbol_size; - blockoffsetF += fp->ofdm_symbol_size; - } + } } else if (packet_type == IF4p5_PRACH) { // FIX: hard coded prach samples length LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe); @@ -303,10 +316,10 @@ void gen_IF4p5_dl_header(IF4p5_header_t *dl_packet, int frame, int subframe) { } -void gen_IF4p5_ul_header(IF4p5_header_t *ul_packet, int frame, int subframe) { +void gen_IF4p5_ul_header(IF4p5_header_t *ul_packet, uint16_t packet_subtype, int frame, int subframe) { ul_packet->type = IF4p5_PACKET_TYPE; - ul_packet->sub_type = IF4p5_PULFFT; + ul_packet->sub_type = packet_subtype; ul_packet->rsvd = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index 1f78e7f77a..e2d4f1f7de 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -37,6 +37,7 @@ #define IF4p5_PULFFT 0x0019 #define IF4p5_PDLFFT 0x0020 #define IF4p5_PRACH 0x0021 +#define IF4p5_PULTICK 0x0022 struct IF4p5_header { /// Type @@ -55,7 +56,7 @@ typedef struct IF4p5_header IF4p5_header_t; void gen_IF4p5_dl_header(IF4p5_header_t*, int, int); -void gen_IF4p5_ul_header(IF4p5_header_t*, int, int); +void gen_IF4p5_ul_header(IF4p5_header_t*, uint16_t, int, int); void gen_IF4p5_prach_header(IF4p5_header_t*, int, int); diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c index ec09550323..3ed1945add 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c @@ -198,6 +198,8 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam packet_size = RAW_IF4p5_PDLFFT_SIZE_BYTES(nblocks); } else if (flags == IF4p5_PULFFT) { packet_size = RAW_IF4p5_PULFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PULTICK) { + packet_size = RAW_IF4p5_PULTICK_SIZE_BYTES; } else if (flags == IF5_MOBIPASS) { packet_size = RAW_IF5_MOBIPASS_SIZE_BYTES; } else { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index ae7c0c9d7b..898382cf6a 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -206,6 +206,8 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); } else if (flags == IF4p5_PULFFT) { packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); + } else if (flags == IF4p5_PULTICK) { + packet_size = UDP_IF4p5_PULTICK_SIZE_BYTES; } else if (flags == IF4p5_PRACH) { packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; } else { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h index 421c2639c6..68b153392b 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h @@ -61,9 +61,11 @@ #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)) +#define RAW_IF4p5_PULTICK_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t) #define RAW_IF4p5_PRACH_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES) #define UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) #define UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) +#define UDP_IF4p5_PULTICK_SIZE_BYTES (sizeof_IF4p5_header_t) #define UDP_IF4p5_PRACH_SIZE_BYTES (sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES) // Mobipass packet sizes diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 3d0674c73e..00d4f220b9 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -181,6 +181,16 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, s->tx_md.has_time_spec = true; else s->tx_md.has_time_spec = false; + + if (device->openair0_cfg[0].tx_freq[0] == device->openair0_cfg[0].rx_freq[0]) { + // for TDD each write should be considered as a burst to trigger the switch on GPIO + s->tx_md.start_of_burst = true; + s->tx_md.end_of_burst = true; + } + else { + s->tx_md.start_of_burst = false; + s->tx_md.end_of_burst = false; + } if (cc>1) { std::vector buff_ptrs; @@ -190,7 +200,7 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, else ret = (int)s->tx_stream->send(buff[0], nsamps, s->tx_md,1e-3); - s->tx_md.start_of_burst = false; + if (ret != nsamps) { printf("[xmit] tx samples %d != %d\n",ret,nsamps); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 99e05a39bf..0ababcc7aa 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -875,29 +875,33 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // Transmit TX buffer based on timestamp from RX // printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); // prepare tx buffer pointers - for (i=0; inb_antennas_tx; i++) - txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; - - txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, - proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, - txp, - fp->samples_per_tti, - fp->nb_antennas_tx, - 1); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - - - if (txs != fp->samples_per_tti) { - LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); - exit_fun( "problem transmitting samples" ); - } + if ((subframe_select(fp,proc->subframe_rx+tx_sfoffset) == SF_DL) || + (subframe_select(fp,proc->subframe_rx+tx_sfoffset) == SF_S)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + + for (i=0; inb_antennas_tx; i++) + txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; + + txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, + proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, + txp, + fp->samples_per_tti, + fp->nb_antennas_tx, + 1); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + + + + if (txs != fp->samples_per_tti) { + LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); + exit_fun( "problem transmitting samples" ); + } + } } - + for (i=0; inb_antennas_rx; i++) rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti]; From 9ee29fb0b2295a92448f28b47838253a2fe25e41 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sat, 14 Jan 2017 14:35:19 +0100 Subject: [PATCH 52/59] changes for S-subframe support in fronthaul --- openair1/PHY/INIT/lte_parms.c | 23 ++++++++++++++++++++++- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 17 ++++++++++++++--- openair1/PHY/impl_defs_lte.h | 6 ++++++ openair1/SCHED/phy_procedures_lte_eNb.c | 9 ++++++--- targets/RT/USER/lte-enb.c | 14 +++++++++++++- 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c index cd879b1a90..f0c63df9e6 100644 --- a/openair1/PHY/INIT/lte_parms.c +++ b/openair1/PHY/INIT/lte_parms.c @@ -22,6 +22,23 @@ #include "defs.h" #include "log.h" +uint16_t dl_S_table_normal[10]={3,9,10,11,12,3,9,10,11,6}; +uint16_t dl_S_table_extended[10]={3,8,9,10,3,8,9,5,0,0}; + +void set_S_config(LTE_DL_FRAME_PARMS *fp) { + + int X = fp->srsX; + + fp->ul_symbols_in_S_subframe=(1+X); + + if ((fp->Ncp==EXTENDED) && (fp->tdd_config_S>7)) + AssertFatal(1==0,"Illegal S subframe configuration for Extended Prefix mode\n"); + + fp->dl_symbols_in_S_subframe = (fp->Ncp==NORMAL)?dl_S_table_normal[fp->tdd_config_S] : dl_S_table_extended[fp->tdd_config_S]; + + +} + int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf) { @@ -29,7 +46,7 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf) LOG_I(PHY,"Initializing frame parms for N_RB_DL %d, Ncp %d, osf %d\n",frame_parms->N_RB_DL,frame_parms->Ncp,osf); - if (frame_parms->Ncp==1) { + if (frame_parms->Ncp==EXTENDED) { frame_parms->nb_prefix_samples0=512; frame_parms->nb_prefix_samples = 512; frame_parms->symbols_per_tti = 12; @@ -37,8 +54,10 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf) frame_parms->nb_prefix_samples0 = 160; frame_parms->nb_prefix_samples = 144; frame_parms->symbols_per_tti = 14; + } + switch(osf) { case 1: log2_osf = 0; @@ -167,6 +186,8 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf) printf("lte_parms.c: Setting N_RB_DL to %d, ofdm_symbol_size %d\n",frame_parms->N_RB_DL, frame_parms->ofdm_symbol_size); + if (frame_parms->frame_type == TDD) set_S_config(frame_parms); + // frame_parms->tdd_config=3; return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 6878ae2684..924eef11b9 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -33,6 +33,7 @@ #include "PHY/defs.h" #include "PHY/TOOLS/alaw_lut.h" #include "PHY/extern.h" +#include "SCHED/defs.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" @@ -54,11 +55,14 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type IF4p5_header_t *packet_header=NULL; eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv); - + int nsym = fp->symbols_per_tti; if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); if (packet_type == IF4p5_PDLFFT) { + if (subframe_select(fp,subframe)==SF_S) + nsym=fp->dl_symbols_in_S_subframe; + db_fulllength = 12*fp->N_RB_DL; db_halflength = (db_fulllength)>>1; slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; @@ -74,7 +78,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type } gen_IF4p5_dl_header(packet_header, frame, subframe); - for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { + for (symbol_id=0; symbol_idCC_id==1) LOG_I(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,frame,subframe,symbol_id); for (element_id=0; element_idofdm_symbol_size - db_halflength - 1; + if (subframe_select(fp,subframe)==SF_S) { + nsym=fp->ul_symbols_in_S_subframe; + slotoffsetF += (fp->ofdm_symbol_size*(fp->symbols_per_tti-nsym)); + blockoffsetF += (fp->ofdm_symbol_size*(fp->symbols_per_tti-nsym)); + } + 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); @@ -117,7 +127,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type gen_IF4p5_ul_header(packet_header, packet_type, frame, subframe); if (packet_type == IF4p5_PULFFT) { - for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { + for (symbol_id=fp->symbols_per_tti-nsym; symbol_idsymbols_per_tti; symbol_id++) { LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); for (element_id=0; element_idframe_rx; int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1); - if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB+offset, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB+offset, proc->subframe_rx ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON+offset, 1 ); - + + + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON+offset, 1 ); start_meas(&eNB->phy_proc_rx); LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_common_RX(%d)\n",eNB->Mod_id,frame,subframe); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 219d9c5d48..5959c1953d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -768,8 +768,18 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { int subframe_tx,frame_tx; symbol_number = 0; - symbol_mask_full = (1<symbols_per_tti)-1; + symbol_mask_full = (subframe_select(fp,*subframe) == SF_S) ? (1<dl_symbols_in_S_subframe) : (1<symbols_per_tti)-1; + // correct for TDD + if (fp->frame_type == TDD) { + while (subframe_select(fp,*subframe) == SF_UL) { + *subframe=*subframe+1; + if (*subframe==10) { + *subframe=0; + *frame=*frame+1; + } + } + } do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); if (proc->first_tx != 0) { @@ -1033,6 +1043,8 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1< Date: Sat, 14 Jan 2017 22:40:36 +0100 Subject: [PATCH 53/59] RRU changes for S-Subframe --- openair1/SCHED/phy_procedures_lte_eNb.c | 9 ++++++++- targets/RT/USER/lte-enb.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 50fd920262..52e4090f81 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2817,7 +2817,14 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){ const int frame = proc->frame_rx; int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1); - if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) { + + if (eNB->node_function == NGFI_RRU_IF4p5) { + /// **** in TDD during DL send_IF4 of ULTICK to RCC **** /// + send_IF4p5(eNB, proc->frame_rx, proc->subframe_rx, IF4p5_PULTICK, 0); + } + return; + } VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB+offset, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB+offset, proc->subframe_rx ); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5d0cfaee82..0b0324a176 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1024,10 +1024,18 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; if (packet_type == IF4p5_PULFFT) { - LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); + LOG_D(PHY,"rx_fh_if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<do_prach) eNB->do_prach(eNB,f,sf); From 84c61990b75cc08b195492091f37d82a65c89cf4 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sat, 14 Jan 2017 16:23:13 +0100 Subject: [PATCH 54/59] fix for S-subframe handling (if4p5_asynch_DL) --- targets/RT/USER/lte-enb.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8a4891cfe0..eed18fdc8d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -768,7 +768,7 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { int subframe_tx,frame_tx; symbol_number = 0; - symbol_mask_full = (subframe_select(fp,*subframe) == SF_S) ? (1<dl_symbols_in_S_subframe) : (1<symbols_per_tti)-1; + // correct for TDD if (fp->frame_type == TDD) { @@ -780,6 +780,7 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } } } + symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<dl_symbols_in_S_subframe) : (1<symbols_per_tti))-1; do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); if (proc->first_tx != 0) { @@ -1047,10 +1048,11 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<first_rx==0) && (f!=*frame)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame); - if (sf!=*subframe) - LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d\n",sf,*subframe); + if ((proc->first_rx==0) && (sf!=*subframe)) + LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); break; } else if (packet_type == IF4p5_PRACH) { LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PRACH\n",f,sf); @@ -1061,8 +1063,9 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]); } while(proc->symbol_mask[*subframe] != symbol_mask_full); - proc->subframe_rx = *subframe; - proc->frame_rx = *frame; + + proc->subframe_rx = sf; + proc->frame_rx = f; proc->symbol_mask[*subframe] = 0; proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event From 2da964bb2d078165d93bd7cc329a4341a889fa16 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 15 Jan 2017 01:07:30 +0100 Subject: [PATCH 55/59] changes for RRU TDD if4p5 --- targets/RT/USER/lte-enb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index eed18fdc8d..43f7f76f98 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -769,6 +769,7 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { symbol_number = 0; + LOG_D(PHY,"fh_asynch_DL_IF4p5: in, frame %d, subframe %d\n",*frame,*subframe); // correct for TDD if (fp->frame_type == TDD) { @@ -780,6 +781,9 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { } } } + + LOG_D(PHY,"fh_asynch_DL_IF4p5: after TDD correction, frame %d, subframe %d\n",*frame,*subframe); + symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<dl_symbols_in_S_subframe) : (1<symbols_per_tti))-1; do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); @@ -788,6 +792,8 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { *subframe = subframe_tx; proc->first_tx = 0; proc->frame_offset = frame_tx - proc->frame_tx; + symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<dl_symbols_in_S_subframe) : (1<symbols_per_tti))-1; + } else { if (frame_tx != *frame) { From 8be18c360b2817a9a7101586f7b23fd8551f9422 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 15 Jan 2017 08:58:26 +0100 Subject: [PATCH 56/59] debugging for RRU if4p5 TDD --- openair2/UTIL/LOG/vcd_signal_dumper.c | 1 + openair2/UTIL/LOG/vcd_signal_dumper.h | 1 + targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 15 +++++--- targets/RT/USER/lte-enb.c | 38 +++++++++++++++----- targets/RT/USER/rru_if4p5_usrp.gtkw | 13 ++++--- 5 files changed, 51 insertions(+), 17 deletions(-) diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index 34fc8e97b8..38a304acb1 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -98,6 +98,7 @@ const char* eurecomVariablesNames[] = { "rxcnt", "trx_ts", "trx_tst", + "trx_write_flags", "tx_ts", "rx_ts", "hw_cnt_rx", diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.h b/openair2/UTIL/LOG/vcd_signal_dumper.h index 0d1c507b74..5e3345e005 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.h +++ b/openair2/UTIL/LOG/vcd_signal_dumper.h @@ -70,6 +70,7 @@ typedef enum { VCD_SIGNAL_DUMPER_VARIABLES_RXCNT, VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, + VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, VCD_SIGNAL_DUMPER_VARIABLES_TX_TS, VCD_SIGNAL_DUMPER_VARIABLES_RX_TS, VCD_SIGNAL_DUMPER_VARIABLES_RX_HWCNT, diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 00d4f220b9..2a2e09f40c 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -177,17 +177,24 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate); - if(flags) + if(flags>0) s->tx_md.has_time_spec = true; else s->tx_md.has_time_spec = false; - if (device->openair0_cfg[0].tx_freq[0] == device->openair0_cfg[0].rx_freq[0]) { - // for TDD each write should be considered as a burst to trigger the switch on GPIO + if (flags == 2) { // start of burst + s->tx_md.start_of_burst = true; + s->tx_md.end_of_burst = false; + } + else if (flags == 3) { // end of burst + s->tx_md.start_of_burst = false; + s->tx_md.end_of_burst = true; + } + else if (flags == 4) { // start and end s->tx_md.start_of_burst = true; s->tx_md.end_of_burst = true; } - else { + else if (flags==1) { // middle of burst s->tx_md.start_of_burst = false; s->tx_md.end_of_burst = false; } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 43f7f76f98..c15e104354 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -899,26 +899,48 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { // printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); // prepare tx buffer pointers - - if ((subframe_select(fp,proc->subframe_rx+tx_sfoffset) == SF_DL) || - (subframe_select(fp,proc->subframe_rx+tx_sfoffset) == SF_S)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + + lte_subframe_t SF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset)%10); + lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+9)%10); + lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+1)%10); + if ((SF_type == SF_DL) || + (SF_type == SF_S)) { for (i=0; inb_antennas_tx; i++) txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; - + + int siglen=fp->samples_per_tti,flags=1; + + if (SF_type == SF_S) { + siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); + flags=3; // end of burst + } + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_DL)) + flags = 2; // start of burst + + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_UL)) + flags = 4; // start of burst and end of burst (only one DL SF between two UL) + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, txp, - fp->samples_per_tti, + siglen, fp->nb_antennas_tx, - 1); + flags); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - if (txs != fp->samples_per_tti) { + if (txs != siglen) { LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); exit_fun( "problem transmitting samples" ); } diff --git a/targets/RT/USER/rru_if4p5_usrp.gtkw b/targets/RT/USER/rru_if4p5_usrp.gtkw index d2a435202f..1a13e6d15f 100644 --- a/targets/RT/USER/rru_if4p5_usrp.gtkw +++ b/targets/RT/USER/rru_if4p5_usrp.gtkw @@ -1,15 +1,15 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Thu Jan 5 06:19:58 2017 +[*] Sun Jan 15 07:26:50 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Thu Jan 5 06:09:13 2017" -[dumpfile_size] 24570356 +[dumpfile_mtime] "Sun Jan 15 07:04:19 2017" +[dumpfile_size] 18140627 [savefile] "/home/uprru1/oai/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw" -[timestart] 23491157000 +[timestart] 29977510000 [size] 1301 716 [pos] 309 0 -*-19.793451 29983948856 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +*-21.793451 29983948856 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 284 [signals_width] 262 [sst_expanded] 1 @@ -17,6 +17,9 @@ @28 functions.trx_read functions.trx_write +@25 +variables.trx_write_flags[63:0] +@28 functions.trx_write_if functions.send_if4 functions.trx_read_if From 73920f3f6e30c3b64a06bf4723f1f658c2f7812e Mon Sep 17 00:00:00 2001 From: Tien-Thinh Nguyen Date: Mon, 16 Jan 2017 16:08:40 +0100 Subject: [PATCH 57/59] [minor modification] fixed the issue related to TX with FDD --- targets/RT/USER/lte-enb.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index c15e104354..814a4cf619 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -406,21 +406,24 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) void tx_fh_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - if ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL); } void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - if ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); } void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - if ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)) + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); } From dce5191542309cf3e36e5196efe6eefe37302021 Mon Sep 17 00:00:00 2001 From: Tien-Thinh Nguyen Date: Wed, 18 Jan 2017 13:53:05 +0100 Subject: [PATCH 58/59] update to make harmony work with Mobipass[Ercom] --- openair1/PHY/LTE_TRANSPORT/if5_tools.c | 178 ++++++++++++++++-- openair2/LAYER2/MAC/pre_processor.c | 4 + targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c | 82 +++++++- .../ETHERNET/USERSPACE/LIB/ethernet_lib.c | 4 +- .../ETHERNET/USERSPACE/LIB/ethernet_lib.h | 1 + targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h | 1 + .../CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf | 6 +- targets/RT/USER/lte-enb.c | 56 ++++-- 8 files changed, 293 insertions(+), 39 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index 7be4c8d1df..5b1c834705 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -21,11 +21,11 @@ /*! \file PHY/LTE_TRANSPORT/if5_tools.c * \brief -* \author S. Sandeep Kumar, Raymond Knopp +* \author S. Sandeep Kumar, Raymond Knopp, Tien-Thinh Nguyen * \date 2016 * \version 0.1 * \company Eurecom -* \email: ee13b1025@iith.ac.in, knopp@eurecom.fr +* \email: ee13b1025@iith.ac.in, knopp@eurecom.fr, tien-thinh.nguyen@eurecom.fr * \note * \warning */ @@ -34,13 +34,21 @@ #include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "UTIL/LOG/vcd_signal_dumper.h" +//#define DEBUG_DL_MOBIPASS +//#define DEBUG_UL_MOBIPASS +#define SUBFRAME_SKIP_NUM_MOBIPASS 8 +int dummy_cnt = 0; +int subframe_skip_extra = 0; +int start_flag = 1; +int offset_cnt = 1; void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) { LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; int32_t *tx_buffer=NULL; + int8_t dummy_buffer[fp->samples_per_tti*2]; uint16_t packet_id=0, i=0; uint32_t spp_eth = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_packet; @@ -89,17 +97,18 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe } } else if (packet_type == IF5_MOBIPASS) { - uint16_t db_fulllength=640; + uint16_t db_fulllength = PAYLOAD_MOBIPASS_NUM_SAMPLES; __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)); + // tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); + tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); 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); - + data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t); + header->flags = 0; header->fifo_status = 0; header->seqno = *seqno; @@ -110,14 +119,14 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe txp128 = (__m128i *) txp[0]; for (packet_id=0; packet_idsamples_per_tti/db_fulllength; packet_id++) { - header->time_stamp = (uint32_t)(proc_timestamp + packet_id*db_fulllength); + header->time_stamp = htonl((uint32_t)(proc_timestamp + packet_id*db_fulllength)); data_block = data_block_head; for (i=0; i>2; i+=2) { t0 = _mm_srai_epi16(*txp128++, 4); t1 = _mm_srai_epi16(*txp128++, 4); - - *data_block++ = _mm_packs_epi16(t0, t1); +// *data_block++ = _mm_packs_epi16(t0, t1); + _mm_storeu_si128(data_block++, _mm_packs_epi16(t0, t1)); } // Write the packet to the fronthaul @@ -129,18 +138,38 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe IF5_MOBIPASS)) < 0) { perror("ETHERNET write for IF5_MOBIPASS\n"); } - +#ifdef DEBUG_DL_MOBIPASS + if ((subframe==0)&&(dummy_cnt == 100)) { + memcpy((void*)&dummy_buffer[packet_id*db_fulllength*2],(void*)data_block_head,db_fulllength*2); + } +#endif header->seqno += 1; } *seqno = header->seqno; - + +#ifdef DEBUG_DL_MOBIPASS + uint8_t txe; + txe = dB_fixed(signal_energy(txp[0],fp->samples_per_tti)); + if (txe > 0){ + LOG_D(PHY,"[Mobipass] frame:%d, subframe:%d, energy %d\n", (proc_timestamp/(10*fp->samples_per_tti))&1023,subframe, txe); + } +#endif } else { AssertFatal(1==0, "send_IF5 - Unknown packet_type %x", packet_type); } free(tx_buffer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 ); - +#ifdef DEBUG_DL_MOBIPASS + if(subframe==0) { + if (dummy_cnt==100) { + write_output("txsigmb.m","txs",(void*)dummy_buffer, fp->samples_per_tti,1, 5); + exit(-1); + } else { + dummy_cnt++; + } + } +#endif return; } @@ -151,6 +180,8 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; uint16_t packet_id=0, i=0; + int8_t dummy_buffer_rx[fp->samples_per_tti*2]; + uint8_t rxe; 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; @@ -202,7 +233,128 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram } else if (packet_type == IF5_MOBIPASS) { - + uint16_t db_fulllength = PAYLOAD_MOBIPASS_NUM_SAMPLES; + openair0_timestamp timestamp_mobipass[fp->samples_per_tti/db_fulllength]; + int lower_offset = 0; + int upper_offset = 70000; + int subframe_skip = 0; + int reset_flag = 0; + int32_t *rx_buffer=NULL; + __m128i *data_block=NULL, *data_block_head=NULL; + __m128i *rxp128; + __m128i r0, r1; + + //rx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); + rx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t)); + IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)rx_buffer + MAC_HEADER_SIZE_BYTES); + data_block_head = (__m128i *)((uint8_t *)rx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t); + + rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][subframe*eNB->frame_parms.samples_per_tti]; + rxp128 = (__m128i *) (rxp[0]); + + eNB_proc_t *proc = &eNB->proc; +/* + // while(packet_idsamples_per_tti/db_fulllength) { + data_block = data_block_head; + + eNB->ifdevice.trx_read_func(&eNB->ifdevice, + &ts0, + (void**)&rx_buffer, + db_fulllength, + 1 + ); + + if ((header->seqno == 1)&&(first_packet==1)) { + first_packet = 0; //ignore the packets before synchnorization + packet_id = 0; + ts_offset = ntohl(ts0); + } + if (first_packet==0) { + packet_cnt++; + ts = ntohl(ts0); + packet_id = (ts-ts_offset)/db_fulllength; + packet_id = packet_id % (fp->samples_per_tti/db_fulllength); + + printf("[IF5_tools]packet_id:%d\n", packet_id); + // if (ts_stored == 0) { + // ts_stored = 1; + *proc_timestamp = ntohl(ts - (packet_id*db_fulllength)); + // } + rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][(subframe*eNB->frame_parms.samples_per_tti)+packet_id*db_fulllength]; + rxp128 = (__m128i *) (rxp[0]); + + for (i=0; i>2; i+=2) { + r0 = _mm_loadu_si128(data_block++); + *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpacklo_epi8(r0,r0),8),4); + *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpackhi_epi8(r0,r0),8),4); + } + } + // }//end while +*/ + + + packet_id=0; + while(packet_idsamples_per_tti/db_fulllength) { + data_block = data_block_head; + + eNB->ifdevice.trx_read_func(&eNB->ifdevice, + ×tamp_mobipass[packet_id], + (void**)&rx_buffer, + db_fulllength, + 1 + ); +#ifdef DEBUG_UL_MOBIPASS + if (((proc->timestamp_tx + lower_offset) > ntohl(timestamp_mobipass[packet_id])) || ((proc->timestamp_tx + upper_offset) < ntohl(timestamp_mobipass[packet_id]))) { + //ignore the packet + subframe_skip_extra = (subframe_skip_extra + 1)%67; + LOG_D("[Mobipass] ignored packet, id:[%d,%d], proc->timestamp_tx:%llu, proc->timestamp_rx:%llu, seqno:%d\n", packet_id,subframe_skip_extra, proc->timestamp_tx, ntohl(timestamp_mobipass[packet_id]), header->seqno); + } +#endif + //skip SUBFRAME_SKIP_NUM_MOBIPASS additional UL packets + if ((start_flag == 1) && (subframe_skip < SUBFRAME_SKIP_NUM_MOBIPASS)){ + subframe_skip++; + offset_cnt = header->seqno; + } else { + if ((offset_cnt != header->seqno) && (start_flag == 0) && (proc->first_rx > 3)){ +#ifdef DEBUG_UL_MOBIPASS + LOG_D(PHY,"[Mobipass] Reset sequence number, offset_cnt:%d, header->seqno:%d, packet_id:%d\n", offset_cnt, header->seqno, packet_id); +#endif + reset_flag=1; + } + if ((reset_flag == 1) && (proc->first_rx > 3 ) && (start_flag == 0) && (packet_id == 0)) { + packet_id = 1; + reset_flag = 0; + } + start_flag = 0; + + //store rxdata and increase packet_id + rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][(subframe*eNB->frame_parms.samples_per_tti)+packet_id*db_fulllength]; + rxp128 = (__m128i *) (rxp[0]); + for (i=0; i>2; i+=2) { + r0 = _mm_loadu_si128(data_block++); + *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpacklo_epi8(r0,r0),8),4); + *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpackhi_epi8(r0,r0),8),4); + } + packet_id++; + offset_cnt = (header->seqno+1)&255; + } + }//end while + + *proc_timestamp = ntohl(timestamp_mobipass[0]); +#ifdef DEBUG_UL_MOBIPASS + LOG_I(PHY,"[Mobipass][Recv_MOBIPASS] timestamp: %llu\n ", *proc_timestamp); +if (eNB->CC_id>0) { + rxe = dB_fixed(signal_energy(rxp[0],fp->samples_per_tti)); + if (rxe > 0){ + LOG_I(PHY,"[Mobipass] frame:%d, subframe:%d, energy %d\n", (*proc_timestamp/(10*fp->samples_per_tti))&1023,subframe, rxe); +// write_output("rxsigmb.m","rxs",(void*)dummy_buffer_rx, fp->samples_per_tti,1, 5); +// exit(-1); + } +} +#endif + + + } else { AssertFatal(1==0, "recv_IF5 - Unknown packet_type %x", packet_type); } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 5024aa605d..f0679098da 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -759,6 +759,10 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, #endif LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); // initialize harq_pid and round + + if (eNB_UE_stats == NULL) + return; + mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti, frameP,subframeP, &ue_sched_ctl->harq_pid[CC_id], diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c index 3ed1945add..5815f2b1a6 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c @@ -21,7 +21,7 @@ /*! \file ethernet_lib.c * \brief API to stream I/Q samples over standard ethernet - * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp + * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp, Tien-Thinh Nguyen * \date 2015 * \version 0.2 * \company Eurecom @@ -45,7 +45,7 @@ #include "common_lib.h" #include "ethernet_lib.h" -#define DEBUG 0 +//#define DEBUG 0 //struct sockaddr_ll dest_addr[MAX_INST]; //struct sockaddr_ll local_addr[MAX_INST]; @@ -93,7 +93,11 @@ int eth_socket_init_raw(openair0_device *device) { eth->local_addr_ll.sll_family = AF_PACKET; eth->local_addr_ll.sll_ifindex = eth->if_index.ifr_ifindex; /* hear traffic from specific protocol*/ - eth->local_addr_ll.sll_protocol = htons((short)device->openair0_cfg->my_port); + if (eth->flags == ETH_RAW_IF5_MOBIPASS) { + eth->local_addr_ll.sll_protocol = htons(0xbffe); + } else{ + eth->local_addr_ll.sll_protocol = htons((short)device->openair0_cfg->my_port); + } eth->local_addr_ll.sll_halen = ETH_ALEN; eth->local_addr_ll.sll_pkttype = PACKET_OTHERHOST; eth->addr_len = sizeof(struct sockaddr_ll); @@ -350,6 +354,78 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam } +int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { + // Read nblocks info from packet itself + + int nblocks = nsamps; + int bytes_received=0; + eth_state_t *eth = (eth_state_t*)device->priv; + + ssize_t packet_size = 28; //MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t ; +// ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 640*sizeof(int16_t); + + bytes_received = recv(eth->sockfd, + buff[0], + packet_size, + MSG_PEEK); + + if (bytes_received ==-1) { + eth->num_rx_errors++; + perror("[MOBIPASS]ETHERNET IF5 READ (header): "); + exit(-1); + } + + IF5_mobipass_header_t *test_header = (IF5_mobipass_header_t*)((uint8_t *)buff[0] + MAC_HEADER_SIZE_BYTES); + *timestamp = test_header->time_stamp; + packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 640*sizeof(int16_t); + + while(bytes_received < packet_size) { + bytes_received = recv(eth->sockfd, + buff[0], + packet_size, + 0); + if (bytes_received ==-1) { + eth->num_rx_errors++; + perror("[MOBIPASS] ETHERNET IF5 READ (payload): "); + exit(-1); + } else { + eth->rx_actual_nsamps = bytes_received>>1; + eth->rx_count++; + } + } + + eth->rx_nsamps = nsamps; + return(bytes_received); + + +/* + if (bytes_received > 0) { + while(bytes_received < packet_size) { + bytes_received = recv(eth->sockfd, + buff[0], + packet_size, + 0); + if (bytes_received ==-1) { + eth->num_rx_errors++; + perror("ETHERNET IF5_MOBIPASS READ (payload): "); + exit(-1); + } else { + eth->rx_actual_nsamps = bytes_received>>1; + eth->rx_count++; + } + } + if (bytes_received == packet_size){ + IF5_mobipass_header_t *test_header = (IF5_mobipass_header_t*)((uint8_t *)buff[0] + MAC_HEADER_SIZE_BYTES); + *timestamp = test_header->time_stamp; + } + + eth->rx_nsamps = nsamps; + } + + return(bytes_received); +*/ +} + int eth_set_dev_conf_raw(openair0_device *device) { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 732d4d31c9..6f93ba4853 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -87,6 +87,8 @@ int trx_eth_start(openair0_device *device) { } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { printf("Setting ETHERNET to RAW_IF5_MODE\n"); if (eth_socket_init_raw(device)!=0) return -1; + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; + } else { printf("Setting ETHERNET to UDP_IF5_MODE\n"); if (eth_socket_init_udp(device)!=0) return -1; @@ -363,7 +365,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth device->trx_read_func = trx_eth_read_udp_IF4p5; } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { device->trx_write_func = trx_eth_write_raw_IF4p5; - device->trx_read_func = trx_eth_read_raw_IF4p5; + device->trx_read_func = trx_eth_read_raw_IF5_mobipass; } else { //device->trx_write_func = trx_eth_write_udp_IF4p5; //device->trx_read_func = trx_eth_read_udp_IF4p5; diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h index fabb9f89fd..9f555beaa9 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h @@ -230,6 +230,7 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags); int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); +int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags); int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); int eth_get_dev_conf_raw(openair0_device *device); diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h index 68b153392b..5fdb962b09 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h @@ -71,3 +71,4 @@ // Mobipass packet sizes #define RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES 1280 #define RAW_IF5_MOBIPASS_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES) +#define PAYLOAD_MOBIPASS_NUM_SAMPLES 640 diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf index 9ce8fac59f..1afa860c16 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf @@ -17,7 +17,7 @@ eNBs = mobile_country_code = "208"; - mobile_network_code = "93"; + mobile_network_code = "92"; ////////// Physical parameters: @@ -129,7 +129,7 @@ eNBs = prach_root = 0; prach_config_index = 0; prach_high_speed = "DISABLE"; - prach_zero_correlation = 1; + prach_zero_correlation = 3; prach_freq_offset = 2; pucch_delta_shift = 1; pucch_nRB_CQI = 1; @@ -265,7 +265,7 @@ eNBs = rrh_gw_active = "yes"; tr_preference = "raw_if5_mobipass"; rf_preference = "usrp_b200"; - iq_txshift = 4; + iq_txshift = 0; tx_sample_advance = 80; tx_scheduling_advance = 9; } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 814a4cf619..686a690b2f 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -279,6 +279,7 @@ static inline void wait_sync(char *thread_name) { void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { + int CC_id = phy_vars_eNB->proc.CC_id; unsigned int aa,slot_offset; //int dummy_tx_b[7680*4] __attribute__((aligned(32))); int i, tx_offset; @@ -370,9 +371,9 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)dummy_tx_b)[2*i+1]<common_vars.txdata[0][aa][tx_offset])[0] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0]<common_vars.txdata[0][aa][tx_offset])[0] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0]<common_vars.txdata[0][aa][tx_offset])[1] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1]<common_vars.txdata[0][aa][tx_offset])[1] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1]<frame_parms,subframe) == SF_S) { @@ -662,26 +663,37 @@ void fh_if5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { eNB_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); + recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); - proc->subframe_rx = (proc->timestamp_rx/fp->samples_per_tti)%10; - proc->frame_rx = (proc->timestamp_rx/(10*fp->samples_per_tti))&1023; - - if (proc->first_rx != 0) { - proc->first_rx = 0; + int offset_mobipass = 40120; + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10; + proc->frame_rx = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023; + + if (proc->first_rx == 1) { + proc->first_rx =2; *subframe = proc->subframe_rx; *frame = proc->frame_rx; + LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",proc->timestamp_rx,proc->frame_rx,proc->subframe_rx); } else { if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"fh_if5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx); + //exit_fun("Exiting"); } if (proc->frame_rx != *frame) { - LOG_E(PHY,"fh_if5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->frame_rx,*frame); - exit_fun("Exiting"); + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx); + // exit_fun("Exiting"); } + // temporary solution + *subframe = proc->subframe_rx; + *frame = proc->frame_rx; } + + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + } // eNodeB_3GPP_BBU // asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU) @@ -1218,11 +1230,16 @@ void wakeup_slaves(eNB_proc_t *proc) { exit_fun( "error locking mutex_rxtx" ); break; } - + + while (slave_proc->instance_cnt_FH == 0) { + // LOG_W( PHY,"[eNB] Frame:%d , eNB rx_fh_slave thread busy!! (cnt_FH %i)\n", proc->frame_rx,slave_proc->instance_cnt_FH ); + usleep(500); + } + int cnt_slave = ++slave_proc->instance_cnt_FH; slave_proc->frame_rx = proc->frame_rx; slave_proc->subframe_rx = proc->subframe_rx; - slave_proc->timestamp_rx = proc->timestamp_rx; + //slave_proc->timestamp_rx = proc->timestamp_rx; slave_proc->timestamp_tx = proc->timestamp_tx; pthread_mutex_unlock( &slave_proc->mutex_FH ); @@ -1483,6 +1500,7 @@ static void* eNB_thread_single( void* param ) { eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB->CC_id = proc->CC_id; void *rxp[2],*rxp2[2]; @@ -1610,7 +1628,7 @@ static void* eNB_thread_single( void* param ) { } if (eNB->CC_id==1) - LOG_I(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", + LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe); // synchronization on FH interface, acquire signals/data and block @@ -1751,7 +1769,7 @@ void init_eNB_proc(int inst) { } //for multiple CCs: setup master and slaves - /* + /* for (CC_id=0; CC_id= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc); } } - }*/ - + } +*/ /* setup PHY proc TX sync mechanism */ pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); @@ -2144,7 +2162,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst } } - if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[0])!=0) { + if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) { printf("Exiting, cannot initialize eNodeB Buffers\n"); exit(-1); } From 56241235cf1b1c5c51d8963700a74393d35ae051 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 20 Jan 2017 08:44:41 +0100 Subject: [PATCH 59/59] rcc configuration file band 7 if5. --- .../PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf index e8e0e6dadb..7541fa1ee1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf @@ -150,7 +150,7 @@ eNBs = ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; ENB_INTERFACE_NAME_FOR_S1U = "lo"; - ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 };