From 094f439626250f3dc5e28714a13d924f9083a2de Mon Sep 17 00:00:00 2001 From: luhan wang Date: Wed, 21 Sep 2016 09:18:31 +0200 Subject: [PATCH 01/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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/97] 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 963ccb9badab05d0f18d8306c0e9ece420e99fbd Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Thu, 17 Nov 2016 11:57:14 +0100 Subject: [PATCH 13/97] some changes for tx-gain setting --- targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp | 21 ++++++------------- .../CONF/enb.band7.tm1.lmssdr.conf | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp index c1e3cb81c1..3abcbbac5a 100644 --- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp +++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp @@ -131,18 +131,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) { */ int trx_lms_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) { - /* double gv = openair0_cfg[0].rx_gain[0] - openair0_cfg[0].rx_gain_offset[0]; - - if (gv > 31) { - printf("RX Gain 0 too high, reduce by %f dB\n",gv-31); - gv = 31; - } - if (gv < 0) { - printf("RX Gain 0 too low, increase by %f dB\n",-gv); - gv = 0; - } - printf("[LMS] Setting 7002M G_PGA_RBB to %d\n", (uint16_t)gv); - LMS_WriteParam(lms_device,LMS7param(G_PGA_RBB),(uint16_t)gv);*/ + LMS_SetNormalizedGain(lms_device, LMS_CH_TX, 0, openair0_cfg[0].tx_gain[0]/100.0); + LMS_SetNormalizedGain(lms_device, LMS_CH_RX, 0, openair0_cfg[0].rx_gain[0]/openair0_cfg[0].rx_gain_offset[0]); return(0); } @@ -209,10 +199,8 @@ int trx_lms_start(openair0_device *device){ LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 3); LMS_SetAntenna(lms_device, LMS_CH_TX, 0, 2); - trx_lms_set_gains(device, device->openair0_cfg); - /*LMS_SetNormalizedGain(lms_device, LMS_CH_TX, 0, 0.175); - LMS_SetNormalizedGain(lms_device, LMS_CH_RX, 0, 0.65);*/ + for (int i = 0; i< device->openair0_cfg->rx_num_channels; i++) { if (LMS_SetLPFBW(lms_device,LMS_CH_RX,i,device->openair0_cfg->rx_bw)!=0) @@ -239,6 +227,9 @@ int trx_lms_start(openair0_device *device){ tx_stream.throughputVsLatency = 0.1; tx_stream.dataFmt = lms_stream_t::LMS_FMT_I12; tx_stream.isTx = true; + + trx_lms_set_gains(device, device->openair0_cfg); + if (LMS_SetupStream(lms_device, &tx_stream)!=0) printf("TX stream setup failed %s\n",LMS_GetLastErrorMessage()); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf index b0ef9e0374..d912b1a102 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf @@ -39,7 +39,7 @@ eNBs = nb_antennas_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; - tx_gain = 60; + tx_gain = 100; rx_gain = 111; prach_root = 0; prach_config_index = 0; From afbab21a54ddcc90be83297b6e29def2476f6f24 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 18 Nov 2016 13:40:14 -0800 Subject: [PATCH 14/97] 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 15/97] 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 16/97] 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 17/97] 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 18/97] 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 19/97] 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 20/97] 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 21/97] 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 22/97] 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 23/97] 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 24/97] 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 25/97] 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 26/97] 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 27/97] 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 28/97] 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 29/97] 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 30/97] 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 31/97] 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 32/97] 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 33/97] 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 34/97] 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 35/97] 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 36/97] 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 37/97] 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 38/97] 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 39/97] 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 40/97] 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 41/97] 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 42/97] 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 43/97] 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 44/97] 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 45/97] 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 46/97] 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 47/97] 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 48/97] 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 49/97] 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 50/97] 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 c1360397ed37cc6e6c05f0ff9cbcf8e18fdd543e Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Sat, 7 Jan 2017 14:55:04 +0100 Subject: [PATCH 51/97] CMakeList.txt changes for LMSSDR, lmssdr config file 50 PRB, rx gain setting in lms_lib.cpp --- cmake_targets/CMakeLists.txt | 1 + targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp | 9 ++++++--- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 714a732132..26d297f46f 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -554,6 +554,7 @@ elseif (${RF_BOARD} STREQUAL "OAI_BLADERF") elseif (${RF_BOARD} STREQUAL "OAI_LMSSDR") include_directories("${OPENAIR_TARGETS}/ARCH/LMSSDR/USERSPACE/LIB") + include_directories("/usr/local/include/lime") LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/lmsSDR") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/lms7002m") diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp index c2063527d0..bd58bb7484 100644 --- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp +++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp @@ -37,6 +37,8 @@ * @{ */ #include +#include +#include #include "common_lib.h" lms_device_t* lms_device; @@ -46,8 +48,7 @@ lms_stream_t tx_stream; #define RXDCLENGTH 4096 #define NUMBUFF 32 -int16_t cos_fsover8[8] = {2047, 1447, 0, -1448, -2047, -1448, 0, 1447}; -int16_t cos_3fsover8[8] = {2047, -1448, 0, 1447, -2047, 1447, 0, -1448}; +using namespace lime; extern "C" { @@ -145,7 +146,9 @@ int trx_lms_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) gv = 0; } printf("[LMS] Setting 7002M G_PGA_RBB to %d\n", (int16_t)gv); - lms7->Modify_SPI_Reg_bits(LMS7param(G_PGA_RBB),(int16_t)gv); + LMS7002M lms7; + lms7.SetConnection(lms7.GetConnection()); + lms7.Modify_SPI_Reg_bits(LMS7param(G_PGA_RBB),(int16_t)gv); return(0); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf index af9ed2c221..b01537d78d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.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 = 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 }; From c70e705aa43e426b0b2c44ee3bb1e18c32d92895 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Wed, 11 Jan 2017 16:10:27 +0100 Subject: [PATCH 52/97] lmssdr configuration file --- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf index b01537d78d..1e4482364d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf @@ -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"; From 5715de89f2fb7a3f626f8e945d453e89e43fe64b Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 13 Jan 2017 14:17:26 +0100 Subject: [PATCH 53/97] 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 54/97] 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 55/97] 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 56/97] 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 57/97] 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 58/97] 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 59/97] 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 60/97] [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 dc8190dc6adffd61ce62edcf7d22a71735847ae6 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Mon, 16 Jan 2017 17:44:43 +0200 Subject: [PATCH 61/97] Fixed issue with #pragma warnings in liblfds --- .../UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700.h | 6 +++--- .../liblfds7.0.0/liblfds700/inc/liblfds700/lfds700_misc.h | 2 +- .../src/lfds700_ringbuffer/lfds700_ringbuffer_cleanup.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700.h b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700.h index fdda50cefb..4f83d8d9a0 100644 --- a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700.h +++ b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700.h @@ -4,9 +4,9 @@ #define LIBLFDS700_H /***** pragmas on *****/ - #pragma warning( disable : 4324 ) // TRD : 4324 disables MSVC warnings for structure alignment padding due to alignment specifiers +// #pragma warning( disable : 4324 ) // TRD : 4324 disables MSVC warnings for structure alignment padding due to alignment specifiers - #pragma prefast( disable : 28113 28182 28183, "blah" ) +// #pragma prefast( disable : 28113 28182 28183, "blah" ) /***** includes *****/ #include "liblfds700/lfds700_porting_abstraction_layer_compiler.h" @@ -25,7 +25,7 @@ #include "liblfds700/lfds700_stack.h" /***** pragmas off *****/ - #pragma warning( default : 4324 ) +// #pragma warning( default : 4324 ) #endif diff --git a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700/lfds700_misc.h b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700/lfds700_misc.h index 014f72dac5..79eb3e7e5a 100644 --- a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700/lfds700_misc.h +++ b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc/liblfds700/lfds700_misc.h @@ -175,7 +175,7 @@ void lfds700_misc_prng_init( struct lfds700_misc_prng_state *ps ); void lfds700_misc_query( enum lfds700_misc_query query_type, void *query_input, void *query_output ); /***** public in-line functions *****/ -#pragma prefast( disable : 28112, "blah" ) +// #pragma prefast( disable : 28112, "blah" ) static LFDS700_PAL_INLINE void lfds700_misc_force_store() { diff --git a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/src/lfds700_ringbuffer/lfds700_ringbuffer_cleanup.c b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/src/lfds700_ringbuffer/lfds700_ringbuffer_cleanup.c index 447c93041e..8ab44e46b5 100644 --- a/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/src/lfds700_ringbuffer/lfds700_ringbuffer_cleanup.c +++ b/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/src/lfds700_ringbuffer/lfds700_ringbuffer_cleanup.c @@ -31,7 +31,7 @@ void lfds700_ringbuffer_cleanup( struct lfds700_ringbuffer_state *rs, /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) static void lfds700_ringbuffer_internal_queue_element_cleanup_callback( struct lfds700_queue_state *qs, struct lfds700_queue_element *qe, enum lfds700_misc_flag dummy_element_flag ) { @@ -54,14 +54,14 @@ static void lfds700_ringbuffer_internal_queue_element_cleanup_callback( struct l return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) static void lfds700_ringbuffer_internal_freelist_element_cleanup_callback( struct lfds700_freelist_state *fs, struct lfds700_freelist_element *fe ) { @@ -82,5 +82,5 @@ static void lfds700_ringbuffer_internal_freelist_element_cleanup_callback( struc return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) From 9fc584d1739e7ac9449564403d24e4f37e84b7f7 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Mon, 16 Jan 2017 17:45:58 +0200 Subject: [PATCH 62/97] Fixed FlexRAN-related warnings --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 64 +- .../MAC/flexran_agent_mac_defs.h | 4 +- .../MAC/flexran_agent_mac_internal.c | 64 +- openair2/ENB_APP/enb_config.c | 8 +- openair2/ENB_APP/flexran_agent.c | 15 +- openair2/ENB_APP/flexran_agent_common.c | 351 ++-- openair2/ENB_APP/flexran_agent_common.h | 4 +- .../ENB_APP/flexran_agent_common_internal.c | 49 +- openair2/ENB_APP/flexran_agent_handler.c | 16 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 6 +- .../MAC/flexran_agent_scheduler_dataplane.c | 33 +- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 1624 ++++++++--------- openair2/UTIL/ASYNC_IF/link_manager.c | 7 +- 14 files changed, 1128 insertions(+), 1119 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index b9cad28278..e353f5fde7 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -30,6 +30,7 @@ #include "flexran_agent_extern.h" #include "flexran_agent_common.h" #include "flexran_agent_mac_internal.h" +#include "flexran_agent_net_comm.h" #include "LAYER2/MAC/proto.h" #include "LAYER2/MAC/flexran_agent_mac_proto.h" @@ -60,14 +61,11 @@ int flexran_agent_mac_handle_stats(mid_t mod_id, const void *params, Protocol__F // TODO: Must resolve conflicts among stats requests int i; - void *buffer; - int size; err_code_t err_code; xid_t xid; uint32_t usec_interval, sec_interval; //TODO: We do not deal with multiple CCs at the moment and eNB id is 0 - int cc_id = 0; int enb_id = mod_id; //eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id]; @@ -250,15 +248,15 @@ int flexran_agent_mac_stats_request(mid_t mod_id, Protocol__FlexHeader *header; int i; - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REQUEST, &header) != 0) - goto error; - Protocol__FlexStatsRequest *stats_request_msg; stats_request_msg = malloc(sizeof(Protocol__FlexStatsRequest)); if(stats_request_msg == NULL) goto error; - protocol__flex_stats_request__init(stats_request_msg); + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REQUEST, &header) != 0) + goto error; + stats_request_msg->header = header; stats_request_msg->type = report_config->report_type; @@ -375,20 +373,19 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, Protocol__FlexranMessage **msg) { Protocol__FlexHeader *header; int i, j, k; - int cc_id = 0; int enb_id = mod_id; //eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id]; //UE_list_t *eNB_UE_list= &eNB->UE_list; - - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) - goto error; - Protocol__FlexStatsReply *stats_reply_msg; stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); if (stats_reply_msg == NULL) goto error; protocol__flex_stats_reply__init(stats_reply_msg); + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) + goto error; + stats_reply_msg->header = header; stats_reply_msg->n_ue_report = report_config->nr_ue; @@ -419,7 +416,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, elem = (uint32_t *) malloc(sizeof(uint32_t)*ue_report[i]->n_bsr); if (elem == NULL) goto error; - for (j = 0; j++; j < ue_report[i]->n_bsr) { + for (j = 0; j < ue_report[i]->n_bsr; j++) { // NN: we need to know the cc_id here, consider the first one elem[j] = flexran_get_ue_bsr (enb_id, i, j); } @@ -472,7 +469,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, /* Check flag for creation of MAC CE buffer status report */ if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_CE_BS) { // TODO: Fill in the actual MAC CE buffer status report - ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) | (0 << 3)) & 15; /* Use as bitmap. Set one or more of the; /* Use as bitmap. Set one or more of the + ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) | (0 << 3)) & 15; /* Use as bitmap. Set one or more of the PROTOCOL__FLEX_CE_TYPE__FLPCET_ values found in stats_common.pb-c.h. See flex_ce_type in FlexRAN specification */ @@ -802,6 +799,8 @@ int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg) { } free(dl_report->csi_report[j]->a31csi->sb_cqi); break; + default: + break; } free(dl_report->csi_report[j]); @@ -856,8 +855,6 @@ int flexran_agent_mac_sr_info(mid_t mod_id, const void *params, Protocol__Flexra Protocol__FlexHeader *header; int i; const int xid = *((int *)params); - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UL_SR_INFO, &header) != 0) - goto error; Protocol__FlexUlSrInfo *ul_sr_info_msg; ul_sr_info_msg = malloc(sizeof(Protocol__FlexUlSrInfo)); @@ -866,6 +863,9 @@ int flexran_agent_mac_sr_info(mid_t mod_id, const void *params, Protocol__Flexra } protocol__flex_ul_sr_info__init(ul_sr_info_msg); + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UL_SR_INFO, &header) != 0) + goto error; + ul_sr_info_msg->header = header; ul_sr_info_msg->has_sfn_sf = 1; ul_sr_info_msg->sfn_sf = flexran_get_sfn_sf(mod_id); @@ -923,8 +923,6 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle Protocol__FlexHeader *header; int i,j; const int xid = *((int *)params); - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_SF_TRIGGER, &header) != 0) - goto error; Protocol__FlexSfTrigger *sf_trigger_msg; sf_trigger_msg = malloc(sizeof(Protocol__FlexSfTrigger)); @@ -933,6 +931,9 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle } protocol__flex_sf_trigger__init(sf_trigger_msg); + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_SF_TRIGGER, &header) != 0) + goto error; + frame_t frame; sub_frame_t subframe; @@ -975,8 +976,8 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle dl_info[i]->rnti = flexran_get_ue_crnti(mod_id, i); dl_info[i]->has_rnti = 1; /*Fill in the right id of this round's HARQ process for this UE*/ - int harq_id; - int harq_status; + unsigned char harq_id; + unsigned char harq_status; flexran_get_harq(mod_id, UE_PCCID(mod_id,i), i, frame, subframe, &harq_id, &harq_status); dl_info[i]->harq_process_id = harq_id; dl_info[i]->has_harq_process_id = 1; @@ -1060,10 +1061,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle for (i = 0; i < sf_trigger_msg->n_dl_info; i++) { free(sf_trigger_msg->dl_info[i]->harq_status); } - free(sf_trigger_msg->dl_info); - for (i = 0; i < sf_trigger_msg->n_ul_info; i++) { - free(sf_trigger_msg->ul_info[i]->reception_status); - } + free(sf_trigger_msg->dl_info); free(sf_trigger_msg->ul_info); free(sf_trigger_msg); } @@ -1230,9 +1228,9 @@ int flexran_agent_mac_handle_dl_mac_config(mid_t mod_id, const void *params, Pro *msg = NULL; return 2; - error: - *msg = NULL; - return -1; + // error: + //*msg = NULL; + //return -1; } void flexran_agent_init_mac_agent(mid_t mod_id) { @@ -1252,7 +1250,7 @@ void flexran_agent_send_sr_info(mid_t mod_id) { int size; Protocol__FlexranMessage *msg; void *data; - int priority; + int priority = 0; err_code_t err_code; int xid = 0; @@ -1282,7 +1280,7 @@ void flexran_agent_send_sf_trigger(mid_t mod_id) { int size; Protocol__FlexranMessage *msg; void *data; - int priority; + int priority = 0; err_code_t err_code; int xid = 0; @@ -1310,13 +1308,11 @@ void flexran_agent_send_sf_trigger(mid_t mod_id) { void flexran_agent_send_update_mac_stats(mid_t mod_id) { - Protocol__FlexranMessage *current_report = NULL, *msg; + Protocol__FlexranMessage *current_report = NULL; void *data; int size; err_code_t err_code; - int priority; - - mac_stats_updates_context_t stats_context = mac_stats_context[mod_id]; + int priority = 0; if (pthread_mutex_lock(mac_stats_context[mod_id].mutex)) { goto error; @@ -1437,7 +1433,7 @@ err_code_t flexran_agent_destroy_cont_mac_stats_update(mid_t mod_id) { flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].prev_stats_reply); free(mac_stats_context[mod_id].mutex); - mac_agent_registered[mod_id] = NULL; + mac_agent_registered[mod_id] = 0; return 1; } diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index bb6aed1d8e..9ec8594f88 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -63,8 +63,8 @@ typedef struct { /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) - void (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, - uint32_t state_change); + int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, + uint8_t state_change); void *dl_scheduler_loaded_lib; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index a63225e657..1fa9852487 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -29,6 +29,7 @@ #include #include +#include "flexran_agent_common_internal.h" #include "flexran_agent_mac_internal.h" Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol__FlexranMessage *new_message, @@ -49,11 +50,6 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol old_report = old_message->stats_reply_msg; new_report = new_message->stats_reply_msg; - /*Flags to designate changes in various levels of the message*/ - int stats_had_changes = 0; - int ue_had_change = 0; - int cell_had_change = 0; - /*See how many and which UE reports should be included in the final stats message*/ int n_ue_report = 0; int ue_found = 0; @@ -101,23 +97,6 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol } cell_found = 0; } - - /*TODO: create the reply message based on the findings*/ - /*Create ue report list*/ - if (n_ue_report > 0) { - ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *)); - for (i = 0; i 0) { - cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *)); - for (i = 0; i 0 || n_ue_report > 0) { /*Create header*/ @@ -128,11 +107,30 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol } stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); protocol__flex_stats_reply__init(stats_reply_msg); + stats_reply_msg->header = header; + + /*TODO: create the reply message based on the findings*/ + /*Create ue report list*/ stats_reply_msg->n_ue_report = n_ue_report; - stats_reply_msg->ue_report = ue_report; + if (n_ue_report > 0) { + ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *)); + for (i = 0; iue_report = ue_report; + } + + /*Create cell report list*/ stats_reply_msg->n_cell_report = n_cell_report; - stats_reply_msg->cell_report = cell_report; + if (n_cell_report > 0) { + cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *)); + for (i = 0; icell_report = cell_report; + } + msg = malloc(sizeof(Protocol__FlexranMessage)); if(msg == NULL) goto error; @@ -270,7 +268,7 @@ Protocol__FlexUlCqiReport * copy_ul_cqi_report(Protocol__FlexUlCqiReport * origi ul_report = malloc(sizeof(Protocol__FlexUlCqi *) * full_ul_report->n_cqi_meas); if(ul_report == NULL) goto error; - for(i = 0; i++; i < full_ul_report->n_cqi_meas) { + for(i = 0; i < full_ul_report->n_cqi_meas; i++) { ul_report[i] = malloc(sizeof(Protocol__FlexUlCqi)); if(ul_report[i] == NULL) goto error; @@ -597,22 +595,22 @@ int parse_mac_config(mid_t mod_id, yaml_parser_t *parser) { goto error; } // Check the types of subsystems offered and handle their values accordingly - if (strcmp(event.data.scalar.value, "dl_scheduler") == 0) { + if (strcmp((char *) event.data.scalar.value, "dl_scheduler") == 0) { LOG_D(ENB_APP, "This is for the dl_scheduler subsystem\n"); // Call the proper handler if (parse_dl_scheduler_config(mod_id, parser) == -1) { LOG_D(ENB_APP, "An error occured\n"); goto error; } - } else if (strcmp(event.data.scalar.value, "ul_scheduler") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "ul_scheduler") == 0) { // Call the proper handler LOG_D(ENB_APP, "This is for the ul_scheduler subsystem\n"); goto error; // TODO - } else if (strcmp(event.data.scalar.value, "ra_scheduler") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "ra_scheduler") == 0) { // Call the proper handler // TODO - } else if (strcmp(event.data.scalar.value, "page_scheduler") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "page_scheduler") == 0) { // Call the proper handler // TODO } else { @@ -665,20 +663,20 @@ int parse_dl_scheduler_config(mid_t mod_id, yaml_parser_t *parser) { goto error; } // Check what key needs to be set - if (strcmp(event.data.scalar.value, "behavior") == 0) { + if (strcmp((char *) event.data.scalar.value, "behavior") == 0) { LOG_I(ENB_APP, "Time to set the behavior attribute\n"); yaml_event_delete(&event); if (!yaml_parser_parse(parser, &event)) { goto error; } if (event.type == YAML_SCALAR_EVENT) { - if (load_dl_scheduler_function(mod_id, event.data.scalar.value) == -1) { + if (load_dl_scheduler_function(mod_id, (char *) event.data.scalar.value) == -1) { goto error; } } else { goto error; } - } else if (strcmp(event.data.scalar.value, "parameters") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "parameters") == 0) { LOG_D(ENB_APP, "Now it is time to set the parameters for this subsystem\n"); if (parse_dl_scheduler_parameters(mod_id, parser) == -1) { goto error; @@ -731,7 +729,7 @@ int parse_dl_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) { if (mac_agent_registered[mod_id]) { LOG_D(ENB_APP, "Setting parameter %s\n", event.data.scalar.value); param = dlsym(agent_mac_xface[mod_id]->dl_scheduler_loaded_lib, - event.data.scalar.value); + (char *) event.data.scalar.value); if (param == NULL) { goto error; } diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index fb4c6266ca..1841d8e9a9 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -344,7 +344,7 @@ void enb_config_display(void) #if defined(FLEXRAN_AGENT_SB_IF) printf( "\nFLEXRAN AGENT CONFIG : \n\n"); printf( "\tInterface name: \t%s:\n",enb_properties.properties[i]->flexran_agent_interface_name); - printf( "\tInterface IP Address: \t%s:\n",enb_properties.properties[i]->flexran_agent_ipv4_address); + // printf( "\tInterface IP Address: \t%s:\n",enb_properties.properties[i]->flexran_agent_ipv4_address); printf( "\tInterface PORT: \t%d:\n\n",enb_properties.properties[i]->flexran_agent_port); printf( "\tCache directory: \t%s:\n",enb_properties.properties[i]->flexran_agent_cache); @@ -2494,10 +2494,10 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) enb_properties.properties[enb_properties_index]->flexran_agent_interface_name = strdup(flexran_agent_interface_name); cidr = flexran_agent_ipv4_address; address = strtok(cidr, "/"); - enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address = strdup(address); - /* if (address) { + //enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address = strdup(address); + if (address) { IPV4_STR_ADDR_TO_INT_NWBO (address, enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB Agent !\n" ); - }*/ + } enb_properties.properties[enb_properties_index]->flexran_agent_port = flexran_agent_port; enb_properties.properties[enb_properties_index]->flexran_agent_cache = strdup(flexran_agent_cache); diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index beca1062bd..0dcacd4b81 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -30,6 +30,8 @@ #include "log.h" #include "flexran_agent.h" #include "flexran_agent_mac_defs.h" +#include "flexran_agent_mac.h" +#include "flexran_agent_mac_internal.h" #include "flexran_agent_extern.h" @@ -38,6 +40,8 @@ #include "flexran_agent_net_comm.h" #include "flexran_agent_async.h" +#include + //#define TEST_TIMER flexran_agent_instance_t flexran_agent[NUM_MAX_ENB]; @@ -64,11 +68,10 @@ void *flexran_agent_task(void *args){ void *data; int size; err_code_t err_code; - int priority; + int priority = 0; MessageDef *msg_p = NULL; const char *msg_name = NULL; - instance_t instance; int result; struct flexran_agent_timer_element_s * elem = NULL; @@ -79,7 +82,6 @@ void *flexran_agent_task(void *args){ itti_receive_msg (TASK_FLEXRAN_AGENT, &msg_p); DevAssert(msg_p != NULL); msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: @@ -212,9 +214,8 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti strcpy(local_cache, DEFAULT_FLEXRAN_AGENT_CACHE); } - if (enb_properties->properties[mod_id]->flexran_agent_ipv4_address != NULL) { - strncpy(in_ip, enb_properties->properties[mod_id]->flexran_agent_ipv4_address, sizeof(in_ip) ); - in_ip[sizeof(in_ip) - 1] = 0; // terminate string + if (enb_properties->properties[mod_id]->flexran_agent_ipv4_address != 0) { + inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); } else { strcpy(in_ip, DEFAULT_FLEXRAN_AGENT_IPv4_ADDRESS ); } @@ -237,7 +238,7 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti channel_container_init = 1; } /*Create the async channel info*/ - flexran_agent_instance_t *channel_info = flexran_agent_async_channel_info(mod_id, in_ip, in_port); + flexran_agent_async_channel_t *channel_info = flexran_agent_async_channel_info(mod_id, in_ip, in_port); /*Create a channel using the async channel info*/ channel_id = flexran_agent_create_channel((void *) channel_info, diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 2ccca6602b..22793f16b4 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -32,6 +32,7 @@ #include "flexran_agent_common.h" #include "flexran_agent_common_internal.h" #include "flexran_agent_extern.h" +#include "flexran_agent_net_comm.h" #include "PHY/extern.h" #include "log.h" @@ -110,14 +111,16 @@ int flexran_agent_hello(mid_t mod_id, const void *params, Protocol__FlexranMessa Protocol__FlexHeader *header; /*TODO: Need to set random xid or xid from received hello message*/ xid_t xid = 1; - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_HELLO, &header) != 0) - goto error; Protocol__FlexHello *hello_msg; hello_msg = malloc(sizeof(Protocol__FlexHello)); if(hello_msg == NULL) goto error; protocol__flex_hello__init(hello_msg); + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_HELLO, &header) != 0) + goto error; + hello_msg->header = header; *msg = malloc(sizeof(Protocol__FlexranMessage)); @@ -163,14 +166,16 @@ int flexran_agent_echo_request(mid_t mod_id, const void* params, Protocol__Flexr Protocol__FlexHeader *header; /*TODO: Need to set a random xid*/ xid_t xid = 1; - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REQUEST, &header) != 0) - goto error; - Protocol__FlexEchoRequest *echo_request_msg; + Protocol__FlexEchoRequest *echo_request_msg = NULL; echo_request_msg = malloc(sizeof(Protocol__FlexEchoRequest)); if(echo_request_msg == NULL) goto error; protocol__flex_echo_request__init(echo_request_msg); + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REQUEST, &header) != 0) + goto error; + echo_request_msg->header = header; *msg = malloc(sizeof(Protocol__FlexranMessage)); @@ -217,15 +222,16 @@ int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__Flexran Protocol__FlexEchoRequest *echo_req = input->echo_request_msg; xid = (echo_req->header)->xid; - Protocol__FlexHeader *header; - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REPLY, &header) != 0) - goto error; - - Protocol__FlexEchoReply *echo_reply_msg; + Protocol__FlexEchoReply *echo_reply_msg = NULL; echo_reply_msg = malloc(sizeof(Protocol__FlexEchoReply)); if(echo_reply_msg == NULL) goto error; protocol__flex_echo_reply__init(echo_reply_msg); + + Protocol__FlexHeader *header; + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REPLY, &header) != 0) + goto error; + echo_reply_msg->header = header; *msg = malloc(sizeof(Protocol__FlexranMessage)); @@ -299,7 +305,7 @@ int flexran_agent_destroy_ue_config_reply(Protocol__FlexranMessage *msg) { if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_CONFIG_REPLY_MSG) goto error; free(msg->ue_config_reply_msg->header); - int i, j; + int i; Protocol__FlexUeConfigReply *reply = msg->ue_config_reply_msg; for(i = 0; i < reply->n_ue_config;i++){ @@ -376,7 +382,7 @@ int flexran_agent_destroy_lc_config_request(Protocol__FlexranMessage *msg) { } // call this function to start a nanosecond-resolution timer -struct timespec timer_start(){ +struct timespec timer_start(void) { struct timespec start_time; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start_time); return start_time; @@ -395,11 +401,7 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; Protocol__FlexControlDelegation *control_delegation_msg = input->control_delegation_msg; - uint32_t delegation_type = control_delegation_msg->delegation_type; - - int i; - - struct timespec vartime = timer_start(); + // struct timespec vartime = timer_start(); //Write the payload lib into a file in the cache and load the lib char lib_name[120]; @@ -413,16 +415,15 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ fwrite(control_delegation_msg->payload.data, control_delegation_msg->payload.len, 1, f); fclose(f); - long time_elapsed_nanos = timer_end(vartime); + // long time_elapsed_nanos = timer_end(vartime); *msg = NULL; return 0; - error: - return -1; } int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg) { /*TODO: Dealocate memory for a dynamically allocated control delegation message*/ + return 0; } int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { @@ -437,6 +438,7 @@ int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__Fl int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg) { /*TODO: Dealocate memory for a dynamically allocated agent reconfiguration message*/ + return 0; } @@ -474,7 +476,7 @@ int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ unsigned int flexran_get_current_frame (mid_t mod_id) { - #warning "SFN will not be in [0-1023] when oaisim is used" + // #warning "SFN will not be in [0-1023] when oaisim is used" return ((eNB_MAC_INST *)enb[mod_id])->frame; } @@ -637,7 +639,6 @@ int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id) { LTE_eNB_UE_stats *eNB_UE_stats = NULL; - int pCCid = UE_PCCID(mod_id,ue_id); rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); @@ -679,7 +680,8 @@ int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { return tpc; } -int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, const int frame, const uint8_t subframe, int *id, int *round) { //flag_id_status = 0 then id, else status +int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, const int frame, const uint8_t subframe, + unsigned char *id, unsigned char *round) { //flag_id_status = 0 then id, else status /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ @@ -701,7 +703,7 @@ int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, /* } */ /* return 0; */ - return round; + return *round; } int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { @@ -922,15 +924,11 @@ int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id) { } int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id) { - Enb_properties_array_t *enb_properties; - enb_properties = enb_config_get(); - return enb_properties->properties[mod_id]->rach_raResponseWindowSize[CC_id]; + return enb_config_get()->properties[mod_id]->rach_raResponseWindowSize[CC_id]; } int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id) { - Enb_properties_array_t *enb_properties; - enb_properties = enb_config_get(); - return enb_properties->properties[mod_id]->rach_macContentionResolutionTimer[CC_id]; + return enb_config_get()->properties[mod_id]->rach_macContentionResolutionTimer[CC_id]; } int flexran_get_duplex_mode(mid_t mod_id, int CC_id) { @@ -969,16 +967,19 @@ int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL) - return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL) { + return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { @@ -1040,12 +1041,14 @@ int flexran_get_half_duplex(mid_t ue_id) { // halfduplex = 1; //} //return halfduplex; + return 0; } int flexran_get_intra_sf_hopping(mid_t ue_id) { //TODO:Get proper value //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); //return (0 & ( 1 << (31))); + return 0; } int flexran_get_type2_sb_1(mid_t ue_id) { @@ -1053,11 +1056,13 @@ int flexran_get_type2_sb_1(mid_t ue_id) { //uint8_t temp = 0; //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); //return (temp & ( 1 << (11))); + return 0; } int flexran_get_ue_category(mid_t ue_id) { //TODO:Get proper value //return (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->ue_Category); + return 0; } int flexran_get_res_alloc_type1(mid_t ue_id) { @@ -1065,35 +1070,41 @@ int flexran_get_res_alloc_type1(mid_t ue_id) { //uint8_t temp = 0; //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); //return (temp & ( 1 << (30))); + return 0; } int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL){ + return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; + } else { + return -1; + } + } + else { + return -1; + } } int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { @@ -1110,45 +1121,52 @@ int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { } int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; + } else { + return -1; + } + } + else { + return -1; + } } int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { @@ -1185,32 +1203,39 @@ int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { } int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + // TODO: This needs fixing + return -1; - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; - } - } - else - return -1; + /* struct rrc_eNB_ue_context_s* ue_context_p = NULL; */ + /* uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); */ + + /* ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); */ + + /* if(ue_context_p != NULL) { */ + /* if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ */ + /* return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; */ + /* } else { */ + /* return -1; */ + /* } */ + /* } else { */ + /* return -1; */ + /* } */ } int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { @@ -1233,23 +1258,26 @@ int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { } int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop) - return 2; - else if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop) - return 1; - else - return 0; - } - } - else - return -1; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop) { + return 2; + } else if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop) { + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return -1; + } } int flexran_get_lcg(mid_t ue_id, mid_t lc_id) { @@ -1265,10 +1293,13 @@ int flexran_get_lcg(mid_t ue_id, mid_t lc_id) { int flexran_get_direction(mid_t ue_id, mid_t lc_id) { /*TODO: fill with the value for the rest of LCID*/ - if(lc_id == DCCH | lc_id == DCCH1) + if(lc_id == DCCH || lc_id == DCCH1) { return 2; - else if(lc_id == DTCH) + } else if(lc_id == DTCH) { return 1; + } else { + return -1; + } } int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { @@ -1276,8 +1307,7 @@ int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_cha Protocol__FlexranMessage *msg; Protocol__FlexHeader *header; void *data; - int priority; - err_code_t err_code; + int priority = 0; int xid = 0; @@ -1461,14 +1491,14 @@ int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_cha data = flexran_agent_pack_message(msg, &size); /*Send sr info using the MAC channel of the eNB*/ if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { - err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; goto error; } LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); - return; + return 0; error: LOG_D(FLEXRAN_AGENT, "Could not send UE state message\n"); + return -1; } @@ -1481,15 +1511,17 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl xid = (lc_config_request_msg->header)->xid; int i, j; - Protocol__FlexHeader *header; - if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_LC_CONFIG_REPLY, &header) != 0) - goto error; Protocol__FlexLcConfigReply *lc_config_reply_msg; lc_config_reply_msg = malloc(sizeof(Protocol__FlexLcConfigReply)); if(lc_config_reply_msg == NULL) goto error; protocol__flex_lc_config_reply__init(lc_config_reply_msg); + + Protocol__FlexHeader *header; + if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_LC_CONFIG_REPLY, &header) != 0) + goto error; + lc_config_reply_msg->header = header; lc_config_reply_msg->n_lc_ue_config = flexran_get_num_ues(mod_id); @@ -1606,15 +1638,16 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl int i; - Protocol__FlexHeader *header; - if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_UE_CONFIG_REPLY, &header) != 0) - goto error; - Protocol__FlexUeConfigReply *ue_config_reply_msg; ue_config_reply_msg = malloc(sizeof(Protocol__FlexUeConfigReply)); if(ue_config_reply_msg == NULL) goto error; protocol__flex_ue_config_reply__init(ue_config_reply_msg); + + Protocol__FlexHeader *header; + if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_UE_CONFIG_REPLY, &header) != 0) + goto error; + ue_config_reply_msg->header = header; ue_config_reply_msg->n_ue_config = flexran_get_num_ues(mod_id); @@ -1805,16 +1838,16 @@ int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol_ Protocol__FlexHeader *header; xid_t xid = 1; - if(flexran_create_header(xid,PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REQUEST, &header) != 0) - goto error; Protocol__FlexEnbConfigRequest *enb_config_request_msg; enb_config_request_msg = malloc(sizeof(Protocol__FlexEnbConfigRequest)); - if(enb_config_request_msg == NULL) goto error; - protocol__flex_enb_config_request__init(enb_config_request_msg); + + if(flexran_create_header(xid,PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REQUEST, &header) != 0) + goto error; + enb_config_request_msg->header = header; *msg = malloc(sizeof(Protocol__FlexranMessage)); @@ -1846,19 +1879,19 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F Protocol__FlexEnbConfigRequest *enb_config_req_msg = input->enb_config_request_msg; xid = (enb_config_req_msg->header)->xid; - int i, j, k; - int cc_id = 0; + int i, j; int enb_id = mod_id; - Protocol__FlexHeader *header; - if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REPLY, &header) != 0) - goto error; - - Protocol__FlexEnbConfigReply *enb_config_reply_msg; + Protocol__FlexEnbConfigReply *enb_config_reply_msg; enb_config_reply_msg = malloc(sizeof(Protocol__FlexEnbConfigReply)); if(enb_config_reply_msg == NULL) goto error; protocol__flex_enb_config_reply__init(enb_config_reply_msg); + + Protocol__FlexHeader *header; + if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REPLY, &header) != 0) + goto error; + enb_config_reply_msg->header = header; enb_config_reply_msg->enb_id = mod_id; diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index 56a52cd0b6..a4ee53067c 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -72,7 +72,7 @@ int flexran_agent_deserialize_message(void *data, int size, Protocol__FlexranMes /* Serialize message and then destroy the input flexran msg. Should be called when protocol message is created dynamically */ void * flexran_agent_pack_message(Protocol__FlexranMessage *msg, - uint32_t * size); + int * size); /* Calls destructor of the given message */ err_code_t flexran_agent_destroy_flexran_message(Protocol__FlexranMessage *msg); @@ -271,7 +271,7 @@ int flexran_get_tpc(mid_t mod_id, mid_t ue_id); a designated frame and subframe. Returns 0 for success. The id and the status of the HARQ process are stored in id and status respectively */ int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, - const int frame, const uint8_t subframe, int *id, int *round); + const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round); /* Uplink power control management*/ int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id); diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index 3026190863..e735b2748b 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -38,13 +38,12 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy yaml_event_t event; int done = 0; - int mapping_started = 0; LOG_I(ENB_APP, "Time to apply a new policy \n"); yaml_parser_initialize(&parser); - yaml_parser_set_input_string(&parser, policy, strlen(policy)); + yaml_parser_set_input_string(&parser, (unsigned char *) policy, strlen(policy)); while (!done) { if (!yaml_parser_parse(&parser, &event)) @@ -52,39 +51,40 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy switch (event.type) { case YAML_STREAM_START_EVENT: + break; case YAML_STREAM_END_EVENT: + break; case YAML_DOCUMENT_START_EVENT: + break; case YAML_DOCUMENT_END_EVENT: break; case YAML_MAPPING_START_EVENT: - mapping_started = 1; break; case YAML_MAPPING_END_EVENT: - mapping_started = 0; break; case YAML_SCALAR_EVENT: // Check the system name and call the proper handler - if (strcmp(event.data.scalar.value, "mac") == 0) { + if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); // Call the mac handler if (parse_mac_config(mod_id, &parser) == -1) { goto error; } - } else if (strcmp(event.data.scalar.value, "rlc") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "rlc") == 0) { // Call the RLC handler LOG_D(ENB_APP, "This is intended for the rlc system\n"); // TODO : Just skip it for now if (skip_system_section(&parser) == -1) { goto error; } - } else if (strcmp(event.data.scalar.value, "pdcp") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "pdcp") == 0) { // Call the PDCP handler LOG_D(ENB_APP, "This is intended for the pdcp system\n"); // TODO : Just skip it for now if (skip_system_section(&parser) == -1) { goto error; } - } else if (strcmp(event.data.scalar.value, "rrc") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "rrc") == 0) { // Call the RRC handler LOG_D(ENB_APP, "This is intended for the rrc system\n"); // TODO : Just skip it for now @@ -159,8 +159,9 @@ int skip_system_section(yaml_parser_t *parser) { if (skip_subsystem_section(parser) == -1) { goto error; } + default: + break; } - done = (event.type == YAML_SEQUENCE_END_EVENT); yaml_event_delete(&event); @@ -199,7 +200,7 @@ int skip_subsystem_section(yaml_parser_t *parser) { goto error; } // Check what key needs to be set - if (strcmp(event.data.scalar.value, "behavior") == 0) { + if (strcmp((char *) event.data.scalar.value, "behavior") == 0) { LOG_D(ENB_APP, "Skipping the behavior attribute\n"); yaml_event_delete(&event); if (!yaml_parser_parse(parser, &event)) { @@ -210,7 +211,7 @@ int skip_subsystem_section(yaml_parser_t *parser) { } else { goto error; } - } else if (strcmp(event.data.scalar.value, "parameters") == 0) { + } else if (strcmp((char *) event.data.scalar.value, "parameters") == 0) { LOG_D(ENB_APP, "Skipping the parameters for this subsystem\n"); if (skip_subsystem_parameters_config(parser) == -1) { goto error; @@ -235,8 +236,6 @@ int skip_subsystem_section(yaml_parser_t *parser) { int skip_subsystem_parameters_config(yaml_parser_t *parser) { yaml_event_t event; - void *param; - int done = 0; int mapping_started = 0; @@ -299,10 +298,10 @@ int skip_parameter_modification(yaml_parser_t *parser) { is_array = 1; break; case YAML_SCALAR_EVENT: - if ((strcmp(event.data.scalar.tag, YAML_INT_TAG) == 0) || - (strcmp(event.data.scalar.tag, YAML_FLOAT_TAG) == 0) || - (strcmp(event.data.scalar.tag, YAML_STR_TAG) == 0) || - (strcmp(event.data.scalar.tag, YAML_BOOL_TAG) == 0)) { + if ((strcmp((char *) event.data.scalar.tag, YAML_INT_TAG) == 0) || + (strcmp((char *) event.data.scalar.tag, YAML_FLOAT_TAG) == 0) || + (strcmp((char *) event.data.scalar.tag, YAML_STR_TAG) == 0) || + (strcmp((char *) event.data.scalar.tag, YAML_BOOL_TAG) == 0)) { // Do nothing } else { // No other type is supported at the moment, so it should be considered an error @@ -351,14 +350,14 @@ int apply_parameter_modification(void *parameter, yaml_parser_t *parser) { is_array = 1; break; case YAML_SCALAR_EVENT: - if (strcmp(event.data.scalar.tag, YAML_INT_TAG) == 0) { - ((int *) parameter)[i] = strtol(event.data.scalar.value, &endptr, 10); - } else if (strcmp(event.data.scalar.tag, YAML_FLOAT_TAG) == 0) { - ((float *) parameter)[i] = strtof(event.data.scalar.value, &endptr); - } else if (strcmp(event.data.scalar.tag, YAML_STR_TAG) == 0) { - strncpy(&((char *) parameter)[i], event.data.scalar.value, event.data.scalar.length); - } else if (strcmp(event.data.scalar.tag, YAML_BOOL_TAG) == 0) { - if (strcmp(event.data.scalar.value, "true") == 0) { + if (strcmp((char *) event.data.scalar.tag, YAML_INT_TAG) == 0) { + ((int *) parameter)[i] = strtol((char *) event.data.scalar.value, &endptr, 10); + } else if (strcmp((char *) event.data.scalar.tag, YAML_FLOAT_TAG) == 0) { + ((float *) parameter)[i] = strtof((char *) event.data.scalar.value, &endptr); + } else if (strcmp((char *) event.data.scalar.tag, YAML_STR_TAG) == 0) { + strncpy(&((char *) parameter)[i], (char *) event.data.scalar.value, event.data.scalar.length); + } else if (strcmp((char *) event.data.scalar.tag, YAML_BOOL_TAG) == 0) { + if (strcmp((char *) event.data.scalar.value, "true") == 0) { ((int *) parameter)[i] = 1; } else { ((int *) parameter)[i] = 0; diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 4967e46923..4326ab6be0 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -73,12 +73,12 @@ flexran_agent_message_destruction_callback message_destruction_callback[] = { flexran_agent_destroy_agent_reconfiguration, }; -static const char *flexran_agent_direction2String[] = { - "", /* not_set */ - "originating message", /* originating message */ - "successfull outcome", /* successfull outcome */ - "unsuccessfull outcome", /* unsuccessfull outcome */ -}; +/* static const char *flexran_agent_direction2String[] = { */ +/* "", /\* not_set *\/ */ +/* "originating message", /\* originating message *\/ */ +/* "successfull outcome", /\* successfull outcome *\/ */ +/* "unsuccessfull outcome", /\* unsuccessfull outcome *\/ */ +/* }; */ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, @@ -123,7 +123,7 @@ error: void * flexran_agent_pack_message(Protocol__FlexranMessage *msg, - uint32_t * size){ + int * size){ void * buffer; err_code_t err_code = PROTOCOL__FLEXRAN_ERR__NO_ERR; @@ -181,7 +181,7 @@ Protocol__FlexranMessage* flexran_agent_process_timeout(long timer_id, void* tim error: LOG_E(FLEXRAN_AGENT, "can't get the timer element\n"); - return TIMER_ELEMENT_NOT_FOUND; + return NULL; } err_code_t flexran_agent_destroy_flexran_message(Protocol__FlexranMessage *msg) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 573a3401b0..93928dbb97 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -442,7 +442,7 @@ schedule_ue_spec( // unsigned char rballoc_sub_UE[MAX_NUM_CCs][NUMBER_OF_UE_MAX][N_RBG_MAX]; // uint16_t pre_nb_available_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; int mcs; - uint16_t min_rb_unit[MAX_NUM_CCs]; + int min_rb_unit[MAX_NUM_CCs]; eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; UE_list_t *UE_list = &eNB->UE_list; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 060e8ab6ca..d661b90a20 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -46,17 +46,17 @@ void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, uint32_t sub * Data plane function for applying the DL decisions of the scheduler */ void flexran_apply_dl_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - const Protocol__FlexranMessage *dl_scheduling_info); + Protocol__FlexranMessage *dl_scheduling_info); /* * Data plane function for applying the UE specific DL decisions of the scheduler */ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - uint32_t n_dl_ue_data, const Protocol__FlexDlData **dl_ue_data); + uint32_t n_dl_ue_data, Protocol__FlexDlData **dl_ue_data); /* * Data plane function for filling the DCI structure */ -void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, const Protocol__FlexDlDci *dl_dci); +void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, Protocol__FlexDlDci *dl_dci); #endif diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c index ff3ef32bd6..c9956bd9ce 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c @@ -56,12 +56,11 @@ #include "SIMULATION/TOOLS/defs.h" // for taus - void flexran_apply_dl_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - const Protocol__FlexranMessage *dl_scheduling_info) { + Protocol__FlexranMessage *dl_scheduling_info) { Protocol__FlexDlMacConfig *mac_config = dl_scheduling_info->dl_mac_config_msg; @@ -89,33 +88,26 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, uint32_t subframe, int *mbsfn_flag, uint32_t n_dl_ue_data, - const Protocol__FlexDlData **dl_ue_data) { + Protocol__FlexDlData **dl_ue_data) { uint8_t CC_id; int UE_id; - int N_RBG[MAX_NUM_CCs]; - unsigned char aggregation; mac_rlc_status_resp_t rlc_status; unsigned char ta_len=0; unsigned char header_len = 0, header_len_tmp = 0; unsigned char sdu_lcids[11],offset,num_sdus=0; - uint16_t nb_rb,nb_rb_temp,total_nb_available_rb[MAX_NUM_CCs],nb_available_rb; + uint16_t nb_rb; uint16_t TBS,j,sdu_lengths[11],rnti,padding=0,post_padding=0; unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; unsigned char round = 0; unsigned char harq_pid = 0; - + // LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; LTE_eNB_UE_stats *eNB_UE_stats = NULL; uint16_t sdu_length_total = 0; - int mcs; - uint16_t min_rb_unit[MAX_NUM_CCs]; short ta_update = 0; eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; UE_list_t *UE_list = &eNB->UE_list; - LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc=1; - static int32_t tpc_accumulated=0; + // static int32_t tpc_accumulated=0; UE_sched_ctrl *ue_sched_ctl; int last_sdu_header_len = 0; @@ -135,7 +127,7 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, dl_dci = dl_data->dl_dci; CC_id = dl_data->serv_cell_index; - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); + // frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); rnti = dl_data->rnti; UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); @@ -357,20 +349,19 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; //Fill the proper DCI of OAI - fill_oai_dci(mod_id, CC_id, rnti, dl_dci); + flexran_fill_oai_dci(mod_id, CC_id, rnti, dl_dci); } } - -void fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, - const Protocol__FlexDlDci *dl_dci) { +void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, + Protocol__FlexDlDci *dl_dci) { void *DLSCH_dci = NULL; DCI_PDU *DCI_pdu; - unsigned char round = 0; unsigned char harq_pid = 0; + // unsigned char round = 0; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - int size_bits, size_bytes; + int size_bits = 0, size_bytes = 0; eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; UE_list_t *UE_list = &eNB->UE_list; LTE_eNB_UE_stats *eNB_UE_stats = NULL; @@ -380,7 +371,7 @@ void fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, uint32_t format; harq_pid = dl_dci->harq_process; - round = dl_dci->rv[0]; + // round = dl_dci->rv[0]; // Note this code is for a specific DCI format DLSCH_dci = (void *)UE_list->UE_template[CC_id][UE_id].DLSCH_DCI[harq_pid]; diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 8975465e77..7f34cbb28f 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -65,698 +65,6 @@ #define ENABLE_MAC_PAYLOAD_DEBUG - -//------------------------------------------------------------------------------ -void -flexran_schedule_ue_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) -//------------------------------------------------------------------------------ -{ - uint8_t CC_id; - int UE_id; - int N_RBG[MAX_NUM_CCs]; - unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len = 0, header_len_tmp = 0, ta_len = 0; - uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], nb_available_rb; - uint16_t TBS, j, rnti, padding=0, post_padding=0; - unsigned char round = 0; - unsigned char harq_pid = 0; - void *DLSCH_dci = NULL; - uint16_t sdu_length_total = 0; - int mcs, mcs_tmp; - uint16_t min_rb_unit[MAX_NUM_CCs]; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - /* TODO: Must move the helper structs to scheduler implementation */ - UE_list_t *UE_list = &eNB->UE_list; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc = 1; - static int32_t tpc_accumulated=0; - UE_sched_ctrl *ue_sched_ctl; - - Protocol__FlexDlData *dl_data[NUM_MAX_UE]; - int num_ues_added = 0; - int channels_added = 0; - - Protocol__FlexDlDci *dl_dci; - Protocol__FlexRlcPdu *rlc_pdus[11]; - uint32_t *ce_bitmap; - Protocol__FlexRlcPdu **rlc_pdu; - int num_tb; - uint32_t ce_flags = 0; - - uint8_t rballoc_sub[25]; - int i; - uint32_t data_to_request; - uint32_t dci_tbs; - uint8_t ue_has_transmission = 0; - uint32_t ndi; - - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - - if (UE_list->head==-1) { - return; - } - - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); - - //weight = get_ue_weight(module_idP,UE_id); - aggregation = 2; // set to the maximum aggregation level - - for (CC_id=0; CC_idcommon_channels[CC_id].vrb_map[i] != 0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = flexran_get_N_RBG(mod_id, CC_id); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx=0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx=0; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); - - start_meas(&eNB->schedule_dlsch_preprocessor); - _dlsch_scheduler_pre_processor(mod_id, - frame, - subframe, - N_RBG, - mbsfn_flag); - stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); - - for (CC_id=0; CC_id0) - continue; - - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - rnti = flexran_get_ue_crnti(mod_id, UE_id); - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - if (rnti==NOT_A_RNTI) { - LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n", UE_id,UE_list->num_UEs); - // mac_xface->macphy_exit("Cannot find rnti for UE_id"); - continue; - } - - if (flexran_get_ue_crnti(mod_id, UE_id) == NOT_A_RNTI) { - LOG_D(MAC,"[eNB] Cannot find UE\n"); - // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - continue; - } - - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { - LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - mod_id, frame, UE_id, CC_id); - //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) - continue; //to next user (there might be rbs availiable for other UEs in TM5 - // else - // break; - } - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - set_ue_dai (subframe, - flexran_get_subframe_assignment(mod_id, CC_id), - UE_id, - CC_id, - UE_list); - //TODO: update UL DAI after DLSCH scheduling - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe,frame_parms); - } - - channels_added = 0; - - // After this point all the UEs will be scheduled - dl_data[num_ues_added] = (Protocol__FlexDlData *) malloc(sizeof(Protocol__FlexDlData)); - protocol__flex_dl_data__init(dl_data[num_ues_added]); - dl_data[num_ues_added]->has_rnti = 1; - dl_data[num_ues_added]->rnti = rnti; - dl_data[num_ues_added]->n_rlc_pdu = 0; - dl_data[num_ues_added]->has_serv_cell_index = 1; - dl_data[num_ues_added]->serv_cell_index = CC_id; - - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); - sdu_length_total=0; - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - -#ifdef EXMIMO - - if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - mcs = cmin(mcs,16); - } - -#endif - - // initializing the rb allocation indicator for each UE - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; - rballoc_sub[j] = 0; - } - - /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ - /* mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb, */ - /* eNB_UE_stats->DL_cqi[0], mcs, */ - /* UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); */ - - dl_dci = (Protocol__FlexDlDci*) malloc(sizeof(Protocol__FlexDlDci)); - protocol__flex_dl_dci__init(dl_dci); - dl_data[num_ues_added]->dl_dci = dl_dci; - - - dl_dci->has_rnti = 1; - dl_dci->rnti = rnti; - dl_dci->has_harq_process = 1; - dl_dci->harq_process = harq_pid; - - /* process retransmission */ - - if (round > 0) { - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - } - - mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /*TODO: Must add this to FlexRAN agent API */ - dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); - - if (nb_rb <= nb_available_rb) { - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j + 1; - } - } - - nb_available_rb -= nb_rb; - aggregation = process_ue_cqi(mod_id, UE_id); - - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - - // Keep the old NDI, do not toggle - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - - ue_has_transmission = 1; - num_ues_added++; - } else { - LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - mod_id, frame, CC_id, UE_id); - ue_has_transmission = 0; - } - //End of retransmission - } else { /* This is a potentially new SDU opportunity */ - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); - TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); - dci_tbs = TBS; - - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - ta_len = (ue_sched_ctl->ta_update!=0) ? 2 : 0; - - dl_data[num_ues_added]->n_ce_bitmap = 2; - dl_data[num_ues_added]->ce_bitmap = (uint32_t *) malloc(sizeof(uint32_t) * 2); - - if (ta_len > 0) { - ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; - } - - /*TODO: Add other flags if DRX and other CE are required*/ - - // Add the control element flags to the flexran message - dl_data[num_ues_added]->ce_bitmap[0] = ce_flags; - dl_data[num_ues_added]->ce_bitmap[1] = ce_flags; - - // TODO : Need to prioritize DRBs - // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) - for (j = 1; j < NB_RB_MAX; j++) { - header_len+=3; - - // Need to see if we have space for data from this channel - if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { - LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len); - //If we have space, we need to see how much data we can request at most (if any available) - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - j, - (dci_tbs-ta_len-header_len)); // transport block set size - - //If data are available in channel j - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[TEST]Have %d bytes in DCCH buffer during first call\n", rlc_status.bytes_in_buffer); - //Fill in as much as possible - data_to_request = cmin(dci_tbs-ta_len-header_len, rlc_status.bytes_in_buffer); - if (data_to_request < 128) { //The header will be one byte less - header_len--; - } - /* if (j == 1 || j == 2) { */ - /* data_to_request+=0; - /* } */ - LOG_D(MAC, "[TEST]Will request %d from channel %d\n", data_to_request, j); - rlc_pdus[channels_added] = (Protocol__FlexRlcPdu *) malloc(sizeof(Protocol__FlexRlcPdu)); - protocol__flex_rlc_pdu__init(rlc_pdus[channels_added]); - rlc_pdus[channels_added]->n_rlc_pdu_tb = 2; - rlc_pdus[channels_added]->rlc_pdu_tb = (Protocol__FlexRlcPduTb **) malloc(sizeof(Protocol__FlexRlcPduTb *) * 2); - rlc_pdus[channels_added]->rlc_pdu_tb[0] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[0]); - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->size = data_to_request; - rlc_pdus[channels_added]->rlc_pdu_tb[1] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[1]); - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->size = data_to_request; - dl_data[num_ues_added]->n_rlc_pdu++; - channels_added++; - //Set this to the max value that we might request - sdu_length_total += data_to_request; - } else { - //Take back the assumption of a header for this channel - header_len -= 3; - } //End rlc_status.bytes_in_buffer <= 0 - } //end of if dci_tbs - ta_len - header_len > 0 - } // End of iterating the logical channels - - // Add rlc_pdus to the dl_data message - dl_data[num_ues_added]->rlc_pdu = (Protocol__FlexRlcPdu **) malloc(sizeof(Protocol__FlexRlcPdu *) * - dl_data[num_ues_added]->n_rlc_pdu); - for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) { - dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; - } - - // there is a payload - if (( dl_data[num_ues_added]->n_rlc_pdu > 0)) { - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - header_len_tmp = header_len; - - if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field - header_len = 1; - } else { //Remove length field from the last SDU - header_len--; - } - - mcs_tmp = mcs; - if (mcs_tmp == 0) { - nb_rb = 4; // don't let the TBS get too small - } else { - nb_rb=min_rb_unit[CC_id]; - } - - LOG_D(MAC,"[TEST]The initial number of resource blocks was %d\n", nb_rb); - LOG_D(MAC,"[TEST] The initial mcs was %d\n", mcs_tmp); - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - LOG_D(MAC,"[TEST]The TBS during rate matching was %d\n", TBS); - - while (TBS < (sdu_length_total + header_len + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - LOG_D(MAC, "[TEST]Had to increase the number of RBs\n"); - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - LOG_D(MAC, "[TEST]We had the exact number of rbs. Time to fill the rballoc subband\n"); - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - LOG_D(MAC, "[TEST]Will only partially fill the bitmap\n"); - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - if ((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j+1; - } - } - - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - - // decrease mcs until TBS falls below required length - while ((TBS > (sdu_length_total + header_len + ta_len)) && (mcs_tmp > 0)) { - mcs_tmp--; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len + ta_len)) && - ((( ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs_tmp < 28)) || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs_tmp <= 15)))) { - mcs_tmp++; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - dci_tbs = TBS; - mcs = mcs_tmp; - - aggregation = process_ue_cqi(mod_id,UE_id); - dl_dci->has_aggr_level = 1; - dl_dci->aggr_level = aggregation; - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - //#warning only for 5MHz channel - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - } - - // do PUCCH power control - // this is the normalized RX power - normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id,UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; - target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 10; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 10; - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - - if (((framex10psubframe+10)<=(frame*10+subframe)) || //normal case - ((framex10psubframe>(frame*10+subframe)) && (((10240-framex10psubframe+frame*10+subframe)>=10)))) //frame wrap-around - if (flexran_get_p0_pucch_status(mod_id, UE_id, CC_id) == 1) { - flexran_update_p0_pucch(mod_id, UE_id, CC_id); - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frame; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframe; - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - mod_id, frame, subframe, harq_pid, tpc, - tpc_accumulated, normalized_rx_power, target_rx_power); - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - for(i=0; iframe_parms.N_RBG; i++) { - rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; - } - - // Toggle NDI - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frame, subframe, UE_id, - UE_list->UE_template[CC_id][UE_id].rnti,harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]= 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid] = tpc; - - // Increase the pointer for the number of scheduled UEs - num_ues_added++; - ue_has_transmission = 1; - } else { // There is no data from RLC or MAC header, so don't schedule - ue_has_transmission = 0; - } - } // End of new scheduling - - // If we has transmission or retransmission - if (ue_has_transmission) { - switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { - case 1: - case 2: - default: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 3: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 4: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 5: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = 1; - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - - break; - case 6: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - break; - } - } - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - - /* TODO */ - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); - } - } // UE_id loop - } // CC_id loop - - // Add all the dl_data elements to the flexran message - (*dl_info)->dl_mac_config_msg->n_dl_ue_data = num_ues_added; - (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) malloc(sizeof(Protocol__FlexDlData *) * num_ues_added); - for (i = 0; i < num_ues_added; i++) { - (*dl_info)->dl_mac_config_msg->dl_ue_data[i] = dl_data[i]; - } - - stop_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); -} - // This function stores the downlink buffer for all the logical channels void _store_dlsch_buffer (module_id_t Mod_id, frame_t frameP, @@ -1024,6 +332,136 @@ void _sort_UEs (module_id_t Mod_idP, } } +void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) { + int i; + UE_list_t *UE_list=&eNB_mac_inst[Mod_id].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for(i=0; irballoc_sub_UE[CC_id][i] == 0) && + (nb_rbs_required_remaining[CC_id][UE_id]>0) && + (ue_sched_ctl->pre_nb_available_rbs[CC_id] < nb_rbs_required[CC_id][UE_id])) { + + // if this UE is not scheduled for TM5 + if (ue_sched_ctl->dl_pow_off[CC_id] != 0 ) { + + if ((i == N_RBG-1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5 ) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit+1; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; + } else { + if (nb_rbs_required_remaining[CC_id][UE_id] >= min_rb_unit){ + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5 ) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; + } + } + } // dl_pow_off[CC_id][UE_id] ! = 0 + } + } +} + +void _dlsch_scheduler_pre_processor_reset (int module_idP, + int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) { + int i,j; + UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t *vrb_map = eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; + int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL/N_RBG; +#ifdef SF05_LIMIT + //int subframe05_limit=0; + int sf05_upper=-1,sf05_lower=-1; +#endif + // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); + + flexran_update_TA(module_idP, UE_id, CC_id); + + if (UE_id==0) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE,ue_sched_ctl->ta_update); + } + nb_rbs_required[CC_id][UE_id]=0; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; + ue_sched_ctl->dl_pow_off[CC_id] = 2; + nb_rbs_required_remaining[CC_id][UE_id] = 0; + +#ifdef SF05_LIMIT + switch (N_RBG) { + case 6: + sf05_lower=0; + sf05_upper=5; + break; + case 8: + sf05_lower=2; + sf05_upper=5; + break; + case 13: + sf05_lower=4; + sf05_upper=7; + break; + case 17: + sf05_lower=7; + sf05_upper=9; + break; + case 25: + sf05_lower=11; + sf05_upper=13; + break; + } +#endif + // Initialize Subbands according to VRB map + for (i=0; irballoc_sub_UE[CC_id][i] = 0; + rballoc_sub[CC_id][i] = 0; +#ifdef SF05_LIMIT + // for avoiding 6+ PRBs around DC in subframe 0-5 (avoid excessive errors) + + if ((subframeP==0 || subframeP==5) && + (i>=sf05_lower && i<=sf05_upper)) + rballoc_sub[CC_id][i]=1; +#endif + // for SI-RNTI,RA-RNTI and P-RNTI allocations + for (j=0;jUE_sched_ctrl[UE_id]; - rnti_t rnti = UE_RNTI(module_idP,UE_id); - uint8_t *vrb_map = eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; - int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL/N_RBG; -#ifdef SF05_LIMIT - //int subframe05_limit=0; - int sf05_upper=-1,sf05_lower=-1; -#endif - LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - - flexran_update_TA(module_idP, UE_id, CC_id); - if (UE_id==0) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE,ue_sched_ctl->ta_update); - } - nb_rbs_required[CC_id][UE_id]=0; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; - ue_sched_ctl->dl_pow_off[CC_id] = 2; - nb_rbs_required_remaining[CC_id][UE_id] = 0; +//------------------------------------------------------------------------------ +void +flexran_schedule_ue_spec_default(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) +//------------------------------------------------------------------------------ +{ + uint8_t CC_id; + int UE_id; + int N_RBG[MAX_NUM_CCs]; + unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len = 0, ta_len = 0; + uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], nb_available_rb; + uint16_t TBS, j, rnti; + unsigned char round = 0; + unsigned char harq_pid = 0; + uint16_t sdu_length_total = 0; + int mcs, mcs_tmp; + uint16_t min_rb_unit[MAX_NUM_CCs]; + eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; + /* TODO: Must move the helper structs to scheduler implementation */ + UE_list_t *UE_list = &eNB->UE_list; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated=0; + UE_sched_ctrl *ue_sched_ctl; -#ifdef SF05_LIMIT - switch (N_RBG) { - case 6: - sf05_lower=0; - sf05_upper=5; - break; - case 8: - sf05_lower=2; - sf05_upper=5; - break; - case 13: - sf05_lower=4; - sf05_upper=7; - break; - case 17: - sf05_lower=7; - sf05_upper=9; - break; - case 25: - sf05_lower=11; - sf05_upper=13; - break; - } -#endif - // Initialize Subbands according to VRB map - for (i=0; irballoc_sub_UE[CC_id][i] = 0; - rballoc_sub[CC_id][i] = 0; -#ifdef SF05_LIMIT - // for avoiding 6+ PRBs around DC in subframe 0-5 (avoid excessive errors) + Protocol__FlexDlData *dl_data[NUM_MAX_UE]; + int num_ues_added = 0; + int channels_added = 0; - if ((subframeP==0 || subframeP==5) && - (i>=sf05_lower && i<=sf05_upper)) - rballoc_sub[CC_id][i]=1; -#endif - // for SI-RNTI,RA-RNTI and P-RNTI allocations - for (j=0;jUE_sched_ctrl[UE_id]; - - for(i=0; irballoc_sub_UE[CC_id][i] == 0) && - (nb_rbs_required_remaining[CC_id][UE_id]>0) && - (ue_sched_ctl->pre_nb_available_rbs[CC_id] < nb_rbs_required[CC_id][UE_id])) { - - // if this UE is not scheduled for TM5 - if (ue_sched_ctl->dl_pow_off[CC_id] != 0 ) { - - if ((i == N_RBG-1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit+1; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; - } else { - if (nb_rbs_required_remaining[CC_id][UE_id] >= min_rb_unit){ - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; - } - } - } // dl_pow_off[CC_id][UE_id] ! = 0 - } + uint32_t data_to_request; + uint32_t dci_tbs; + uint8_t ue_has_transmission = 0; + uint32_t ndi; + + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + + if (UE_list->head==-1) { + return; } + + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); + + //weight = get_ue_weight(module_idP,UE_id); + aggregation = 2; // set to the maximum aggregation level + + for (CC_id=0; CC_idcommon_channels[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = flexran_get_N_RBG(mod_id, CC_id); + + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx=0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx=0; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); + + start_meas(&eNB->schedule_dlsch_preprocessor); + _dlsch_scheduler_pre_processor(mod_id, + frame, + subframe, + N_RBG, + mbsfn_flag); + stop_meas(&eNB->schedule_dlsch_preprocessor); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); + + for (CC_id=0; CC_id0) + continue; + + for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + rnti = flexran_get_ue_crnti(mod_id, UE_id); + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + if (rnti==NOT_A_RNTI) { + LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n", UE_id,UE_list->num_UEs); + // mac_xface->macphy_exit("Cannot find rnti for UE_id"); + continue; + } + + if (flexran_get_ue_crnti(mod_id, UE_id) == NOT_A_RNTI) { + LOG_D(MAC,"[eNB] Cannot find UE\n"); + // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + continue; + } + + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated + CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { + LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + mod_id, frame, UE_id, CC_id); + //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) + continue; //to next user (there might be rbs availiable for other UEs in TM5 + // else + // break; + } + + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + set_ue_dai (subframe, + flexran_get_subframe_assignment(mod_id, CC_id), + UE_id, + CC_id, + UE_list); + //TODO: update UL DAI after DLSCH scheduling + //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe,frame_parms); + } + + channels_added = 0; + + // After this point all the UEs will be scheduled + dl_data[num_ues_added] = (Protocol__FlexDlData *) malloc(sizeof(Protocol__FlexDlData)); + protocol__flex_dl_data__init(dl_data[num_ues_added]); + dl_data[num_ues_added]->has_rnti = 1; + dl_data[num_ues_added]->rnti = rnti; + dl_data[num_ues_added]->n_rlc_pdu = 0; + dl_data[num_ues_added]->has_serv_cell_index = 1; + dl_data[num_ues_added]->serv_cell_index = CC_id; + + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); + sdu_length_total=0; + mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; + +#ifdef EXMIMO + + if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { + mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; + mcs = cmin(mcs,16); + } + +#endif + + // initializing the rb allocation indicator for each UE + for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; + rballoc_sub[j] = 0; + } + + /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ + /* mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb, */ + /* eNB_UE_stats->DL_cqi[0], mcs, */ + /* UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); */ + + dl_dci = (Protocol__FlexDlDci*) malloc(sizeof(Protocol__FlexDlDci)); + protocol__flex_dl_dci__init(dl_dci); + dl_data[num_ues_added]->dl_dci = dl_dci; + + + dl_dci->has_rnti = 1; + dl_dci->rnti = rnti; + dl_dci->has_harq_process = 1; + dl_dci->harq_process = harq_pid; + + /* process retransmission */ + + if (round > 0) { + + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); + LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); + } + + mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; + + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + + /*TODO: Must add this to FlexRAN agent API */ + dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); + + if (nb_rb <= nb_available_rb) { + + if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { + if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && + ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| + (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; + } else { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + } + } + j = j + 1; + } + } + + nb_available_rb -= nb_rb; + aggregation = process_ue_cqi(mod_id, UE_id); + + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + + // Keep the old NDI, do not toggle + ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; + UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; + + ue_has_transmission = 1; + num_ues_added++; + } else { + LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + mod_id, frame, CC_id, UE_id); + ue_has_transmission = 0; + } + //End of retransmission + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); + TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); + dci_tbs = TBS; + + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + ta_len = (ue_sched_ctl->ta_update!=0) ? 2 : 0; + + dl_data[num_ues_added]->n_ce_bitmap = 2; + dl_data[num_ues_added]->ce_bitmap = (uint32_t *) malloc(sizeof(uint32_t) * 2); + + if (ta_len > 0) { + ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; + } + + /*TODO: Add other flags if DRX and other CE are required*/ + + // Add the control element flags to the flexran message + dl_data[num_ues_added]->ce_bitmap[0] = ce_flags; + dl_data[num_ues_added]->ce_bitmap[1] = ce_flags; + + // TODO : Need to prioritize DRBs + // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) + for (j = 1; j < NB_RB_MAX; j++) { + header_len+=3; + + // Need to see if we have space for data from this channel + if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { + LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len); + //If we have space, we need to see how much data we can request at most (if any available) + rlc_status = mac_rlc_status_ind(mod_id, + rnti, + mod_id, + frame, + ENB_FLAG_YES, + MBMS_FLAG_NO, + j, + (dci_tbs-ta_len-header_len)); // transport block set size + + //If data are available in channel j + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[TEST]Have %d bytes in DCCH buffer during first call\n", rlc_status.bytes_in_buffer); + //Fill in as much as possible + data_to_request = cmin(dci_tbs-ta_len-header_len, rlc_status.bytes_in_buffer); + if (data_to_request < 128) { //The header will be one byte less + header_len--; + } + /* if (j == 1 || j == 2) { + data_to_request+=0; + } */ + LOG_D(MAC, "[TEST]Will request %d from channel %d\n", data_to_request, j); + rlc_pdus[channels_added] = (Protocol__FlexRlcPdu *) malloc(sizeof(Protocol__FlexRlcPdu)); + protocol__flex_rlc_pdu__init(rlc_pdus[channels_added]); + rlc_pdus[channels_added]->n_rlc_pdu_tb = 2; + rlc_pdus[channels_added]->rlc_pdu_tb = (Protocol__FlexRlcPduTb **) malloc(sizeof(Protocol__FlexRlcPduTb *) * 2); + rlc_pdus[channels_added]->rlc_pdu_tb[0] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); + protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[0]); + rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_logical_channel_id = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[0]->logical_channel_id = j; + rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_size = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[0]->size = data_to_request; + rlc_pdus[channels_added]->rlc_pdu_tb[1] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); + protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[1]); + rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_logical_channel_id = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[1]->logical_channel_id = j; + rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_size = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[1]->size = data_to_request; + dl_data[num_ues_added]->n_rlc_pdu++; + channels_added++; + //Set this to the max value that we might request + sdu_length_total += data_to_request; + } else { + //Take back the assumption of a header for this channel + header_len -= 3; + } //End rlc_status.bytes_in_buffer <= 0 + } //end of if dci_tbs - ta_len - header_len > 0 + } // End of iterating the logical channels + + // Add rlc_pdus to the dl_data message + dl_data[num_ues_added]->rlc_pdu = (Protocol__FlexRlcPdu **) malloc(sizeof(Protocol__FlexRlcPdu *) * + dl_data[num_ues_added]->n_rlc_pdu); + for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) { + dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; + } + + // there is a payload + if (( dl_data[num_ues_added]->n_rlc_pdu > 0)) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + + if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field + header_len = 1; + } else { //Remove length field from the last SDU + header_len--; + } + + mcs_tmp = mcs; + if (mcs_tmp == 0) { + nb_rb = 4; // don't let the TBS get too small + } else { + nb_rb=min_rb_unit[CC_id]; + } + + LOG_D(MAC,"[TEST]The initial number of resource blocks was %d\n", nb_rb); + LOG_D(MAC,"[TEST] The initial mcs was %d\n", mcs_tmp); + + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + LOG_D(MAC,"[TEST]The TBS during rate matching was %d\n", TBS); + + while (TBS < (sdu_length_total + header_len + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + LOG_D(MAC, "[TEST]Had to increase the number of RBs\n"); + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + LOG_D(MAC, "[TEST]We had the exact number of rbs. Time to fill the rballoc subband\n"); + for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + LOG_D(MAC, "[TEST]Will only partially fill the bitmap\n"); + while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { + if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + if ((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && + ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| + (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1; + } else { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + } + } + j = j+1; + } + } + + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + + // decrease mcs until TBS falls below required length + while ((TBS > (sdu_length_total + header_len + ta_len)) && (mcs_tmp > 0)) { + mcs_tmp--; + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < (sdu_length_total + header_len + ta_len)) && + ((( ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs_tmp < 28)) || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs_tmp <= 15)))) { + mcs_tmp++; + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + dci_tbs = TBS; + mcs = mcs_tmp; + + aggregation = process_ue_cqi(mod_id,UE_id); + dl_dci->has_aggr_level = 1; + dl_dci->aggr_level = aggregation; + + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; + + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + UE_list->UE_template[CC_id][UE_id].DAI++; + // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); + //#warning only for 5MHz channel + update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); + } + + // do PUCCH power control + // this is the normalized RX power + normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id,UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; + target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 10; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 10; + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + + if (((framex10psubframe+10)<=(frame*10+subframe)) || //normal case + ((framex10psubframe>(frame*10+subframe)) && (((10240-framex10psubframe+frame*10+subframe)>=10)))) //frame wrap-around + if (flexran_get_p0_pucch_status(mod_id, UE_id, CC_id) == 1) { + flexran_update_p0_pucch(mod_id, UE_id, CC_id); + + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frame; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframe; + if (normalized_rx_power>(target_rx_power+1)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-1)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + mod_id, frame, subframe, harq_pid, tpc, + tpc_accumulated, normalized_rx_power, target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + for(i=0; iframe_parms.N_RBG; i++) { + rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; + } + + // Toggle NDI + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frame, subframe, UE_id, + UE_list->UE_template[CC_id][UE_id].rnti,harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]= 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + + UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid] = tpc; + + // Increase the pointer for the number of scheduled UEs + num_ues_added++; + ue_has_transmission = 1; + } else { // There is no data from RLC or MAC header, so don't schedule + ue_has_transmission = 0; + } + } // End of new scheduling + + // If we has transmission or retransmission + if (ue_has_transmission) { + switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { + case 1: + case 2: + default: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 3: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 4: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 5: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + + if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + + break; + case 6: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + break; + } + } + + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + + /* TODO */ + //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); + } + } // UE_id loop + } // CC_id loop + + // Add all the dl_data elements to the flexran message + (*dl_info)->dl_mac_config_msg->n_dl_ue_data = num_ues_added; + (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) malloc(sizeof(Protocol__FlexDlData *) * num_ues_added); + for (i = 0; i < num_ues_added; i++) { + (*dl_info)->dl_mac_config_msg->dl_ue_data[i] = dl_data[i]; + } + + stop_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); } diff --git a/openair2/UTIL/ASYNC_IF/link_manager.c b/openair2/UTIL/ASYNC_IF/link_manager.c index 1c9fb72bfe..235acef247 100644 --- a/openair2/UTIL/ASYNC_IF/link_manager.c +++ b/openair2/UTIL/ASYNC_IF/link_manager.c @@ -61,9 +61,9 @@ static void *link_manager_sender_thread(void *_manager) return NULL; -error: - LOG_E(MAC, "%s: error\n", __FUNCTION__); - return NULL; + //error: + //LOG_E(MAC, "%s: error\n", __FUNCTION__); + //return NULL; } /* that thread receives messages from the link and puts them in the queue */ @@ -118,7 +118,6 @@ link_manager_t *create_link_manager( // Make the async interface threads real-time //#ifndef LOWLATENCY struct sched_param sched_param_recv_thread; - struct sched_param sched_param_send_thread; sched_param_recv_thread.sched_priority = sched_get_priority_max(SCHED_RR) - 1; pthread_attr_setschedparam(&attr, &sched_param_recv_thread); From 67e53e72abafff9a122bf6e90aa728d0b6132a90 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 16 Jan 2017 17:07:47 +0100 Subject: [PATCH 63/97] fix the use of get_eNB_UE_stats The function may return NULL if the UE has been dropped in the PHY layer but is still present in the MAC layer. Deal with the NULL case everywhere it's needed. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 23 ++++++++++------- openair2/LAYER2/MAC/pre_processor.c | 30 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 831b00a2f9..ec43c2434b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -751,6 +751,20 @@ void schedule_ulsch_rnti(module_id_t module_idP, continue; } + /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ + /* TODO: refine? */ + drop_ue = 0; + for (n=0; nnumactiveULCCs[UE_id]; n++) { + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); + drop_ue = 1; + break; + } + } + if (drop_ue == 1) + continue; + // loop over all active UL CC_ids for this UE for (n=0; nnumactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list @@ -758,15 +772,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - if (eNB_UE_stats==NULL) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - drop_ue=1; - continue; // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - } - - if (drop_ue==1) - continue; - if (CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti)) { LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); continue; // break; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index ed12d322c1..150f2c15de 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -153,12 +153,25 @@ void assign_rbs_required (module_id_t Mod_id, UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; // UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; + int skip_ue; // clear rb allocations across all CC_ids for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { pCCid = UE_PCCID(Mod_id,UE_id); rnti = UE_list->UE_template[pCCid][UE_id].rnti; + /* skip UE not present in PHY (for any of its active CCs) */ + skip_ue = 0; + for (n=0; nnumactiveCCs[UE_id]; n++) { + CC_id = UE_list->ordered_CCids[n][UE_id]; + if (mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti) == NULL) { + skip_ue = 1; + break; + } + } + if (skip_ue == 1) + continue; + //update CQI information across component carriers for (n=0; nnumactiveCCs[UE_id]; n++) { @@ -262,7 +275,7 @@ int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uin } // This function scans all CC_ids for a particular UE to find the maximum DL CQI - +// it returns -1 if the UE is not found in PHY layer (get_eNB_UE_stats gives NULL) int maxcqi(module_id_t Mod_id,int32_t UE_id) { @@ -276,8 +289,9 @@ int maxcqi(module_id_t Mod_id,int32_t UE_id) eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,UE_RNTI(Mod_id,UE_id)); if (eNB_UE_stats==NULL) { - mac_xface->macphy_exit("maxcqi: could not get eNB_UE_stats\n"); - return 0; // not reached + /* the UE may have been removed in the PHY layer, don't exit */ + //mac_xface->macphy_exit("maxcqi: could not get eNB_UE_stats\n"); + return -1; } if (eNB_UE_stats->DL_cqi[0] > CQI) { @@ -329,7 +343,13 @@ void sort_UEs (module_id_t Mod_idP, round2 = maxround(Mod_idP,rnti2,frameP,subframeP,0); //mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); pCC_id2 = UE_PCCID(Mod_idP,UE_id2); - if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order + /* if 2nd UE is not in PHY, do nothing */ + if (cqi2 == -1) + continue; + /* if 1st UE is not in PHY, swap with 2nd UE */ + if (cqi1 == -1) { + swap_UEs(UE_list,UE_id1,UE_id2,0); + } else if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order swap_UEs(UE_list,UE_id1,UE_id2,0); } else if (round2 == round1) { // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. @@ -758,6 +778,8 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, int sf05_upper=-1,sf05_lower=-1; #endif LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); + if (eNB_UE_stats == NULL) return; + // initialize harq_pid and round mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti, frameP,subframeP, From 8a9ef14e4f04f4dd2032cacecc925be219a5444e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sun, 8 Jan 2017 14:52:29 +0100 Subject: [PATCH 64/97] reduced the max number of antenna ports to 6 to save memory (we are not using antenna port >5 anyway) mult_cpx_conj_vector can now also do multiply add beam_precoding now uses mult_cpx_conj_vector Conflicts: openair1/PHY/MODULATION/beamforming.c --- openair1/PHY/INIT/lte_init.c | 4 +- .../lte_ul_channel_estimation.c | 9 ++-- openair1/PHY/MODULATION/beamforming.c | 43 ++++++++++--------- openair1/PHY/TOOLS/cmult_vv.c | 16 +++++-- openair1/PHY/TOOLS/defs.h | 4 +- openair1/PHY/impl_defs_lte.h | 2 +- openair1/PHY/impl_defs_top.h | 2 +- 7 files changed, 48 insertions(+), 32 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 12bd06bb81..accc54af54 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1304,7 +1304,7 @@ 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++) { + for (i=0; itxdataF[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", @@ -1326,7 +1326,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, #endif } - for (i=0; i<14; i++) { // 14 is the total number of antenna ports + for (i=0; ibeam_weights[eNB_id][i] = (int32_t **)malloc16_clear(fp->nb_antennas_tx*sizeof(int32_t*)); for (j=0; jnb_antennas_tx; j++) { common_vars->beam_weights[eNB_id][i][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index d2bc2e27c0..4fef74dd1c 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -720,10 +720,11 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, //write_output("eNB_srs.m","srs_eNB",common_vars->srs,(frame_parms->ofdm_symbol_size),1,1); mult_cpx_conj_vector((int16_t*) &common_vars->rxdataF[eNB_id][aa][2*frame_parms->ofdm_symbol_size*symbol], - (int16_t*) srs_vars->srs, - (int16_t*) srs_vars->srs_ch_estimates[eNB_id][aa], - frame_parms->ofdm_symbol_size, - 15); + (int16_t*) srs_vars->srs, + (int16_t*) srs_vars->srs_ch_estimates[eNB_id][aa], + frame_parms->ofdm_symbol_size, + 15, + 0); //msg("SRS channel estimation cmult out\n"); #ifdef USER_MODE diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 6557a47ee7..331c4e2421 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -64,27 +64,30 @@ int beam_precoding(int32_t **txdataF, memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size)); 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) { - ((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); + if (p==0 || p==1 || p==5) { + mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1); + //multadd_cpx_vector((int16_t*)txdataF[p],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 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]); - */ - } + /* + for (re=0;reofdm_symbol_size;re++) { + if (txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) { + ((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]); + } + } + */ } } return 0; diff --git a/openair1/PHY/TOOLS/cmult_vv.c b/openair1/PHY/TOOLS/cmult_vv.c index cefa972061..39bfe547e7 100644 --- a/openair1/PHY/TOOLS/cmult_vv.c +++ b/openair1/PHY/TOOLS/cmult_vv.c @@ -41,7 +41,8 @@ int mult_cpx_conj_vector(int16_t *x1, int16_t *x2, int16_t *y, uint32_t N, - int output_shift) + int output_shift, + int madd) { // Multiply elementwise the complex conjugate of x1 with x2. // x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| @@ -55,6 +56,8 @@ int mult_cpx_conj_vector(int16_t *x1, // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; // // output_shift - shift to be applied to generate output + // + // madd - add the output to y uint32_t i; // loop counter @@ -88,7 +91,11 @@ int mult_cpx_conj_vector(int16_t *x1, tmp_im = _mm_srai_epi32(tmp_im,output_shift); tmpy0 = _mm_unpacklo_epi32(tmp_re,tmp_im); tmpy1 = _mm_unpackhi_epi32(tmp_re,tmp_im); - *y_128 = _mm_packs_epi32(tmpy0,tmpy1); + if (madd==0) + *y_128 = _mm_packs_epi32(tmpy0,tmpy1); + else + *y_128 += _mm_packs_epi32(tmpy0,tmpy1); + #elif defined(__arm__) tmp_re = vmull_s16(((simdshort_q15_t *)x1_128)[0], ((simdshort_q15_t*)x2_128)[0]); @@ -110,7 +117,10 @@ int mult_cpx_conj_vector(int16_t *x1, tmp_re = vqshlq_s32(tmp_re,shift); tmp_im = vqshlq_s32(tmp_im,shift); tmpy = vzip_s16(vmovn_s32(tmp_re),vmovn_s32(tmp_im)); - *y_128 = vcombine_s16(tmpy.val[0],tmpy.val[1]); + if (madd==0) + *y_128 = vcombine_s16(tmpy.val[0],tmpy.val[1]); + else + *y_128 += vcombine_s16(tmpy.val[0],tmpy.val[1]); #endif x1_128++; x2_128++; diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/defs.h index 453efc028a..273822c598 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/defs.h @@ -116,13 +116,15 @@ int rotate_cpx_vector(int16_t *x, @param y - output in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| @param N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; @param output_shift - shift to be applied to generate output + @param madd - if not zero result is added to output */ int mult_cpx_conj_vector(int16_t *x1, int16_t *x2, int16_t *y, uint32_t N, - int output_shift); + int output_shift, + int madd); // lte_dfts.c void init_fft(uint16_t size, diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 6635573779..98d6e06f76 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -546,7 +546,7 @@ typedef struct { uint8_t nb_antennas_tx; /// Number of Receive antennas in node uint8_t nb_antennas_rx; - /// Number of Logical transmit antenna ports in eNodeB + /// Number of common transmit antenna ports in eNodeB (1 or 2) uint8_t nb_antenna_ports_eNB; /// PRACH_CONFIG PRACH_CONFIG_COMMON prach_config_common; diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 79e684215c..dd09749fbf 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -177,7 +177,7 @@ #define DMA_BLKS_PER_SLOT (SLOT_LENGTH_BYTES/2048) // Number of DMA blocks per slot #define SLOT_TIME_NS (SLOT_LENGTH_SAMPLES*(1e3)/7.68) // slot time in ns -#define NB_ANTENNA_PORTS_ENB 14 // total number of eNB antenna ports +#define NB_ANTENNA_PORTS_ENB 6 // total number of eNB antenna ports #ifdef EXMIMO #define TARGET_RX_POWER 55 // Target digital power for the AGC From ab57b0ddd3c687ecbc0e7c95e26c1cc4cddfd47b Mon Sep 17 00:00:00 2001 From: Xiwen JIANG Date: Mon, 9 Jan 2017 17:19:15 +0100 Subject: [PATCH 65/97] replace the conjugate vector multiplexing with direct vector multiplexing --- openair1/PHY/MODULATION/beamforming.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 331c4e2421..acf792b519 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -65,11 +65,11 @@ int beam_precoding(int32_t **txdataF, for (p=0; p<14; p++) { if (p==0 || p==1 || p==5) { - mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1); - //multadd_cpx_vector((int16_t*)txdataF[p],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15); + multadd_cpx_vector((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15); + //mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1); - /* - for (re=0;reofdm_symbol_size;re++) { + // if check version + /*for (re=0;reofdm_symbol_size;re++) { if (txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) { ((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); @@ -86,8 +86,7 @@ int beam_precoding(int32_t **txdataF, ((int16_t*)&txdataF_BF[aa][re])[0], ((int16_t*)&txdataF_BF[aa][re])[1]); } - } - */ + }*/ } } return 0; From a5e6690dedac1222164afa7c2afad654431edcf4 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 18 Jan 2017 09:33:39 +0100 Subject: [PATCH 66/97] adding multadd_cpx_vector --- openair1/PHY/TOOLS/cmult_vv.c | 79 +++++++++++++++++++++++++++++++++++ openair1/PHY/TOOLS/defs.h | 19 +++++++++ 2 files changed, 98 insertions(+) diff --git a/openair1/PHY/TOOLS/cmult_vv.c b/openair1/PHY/TOOLS/cmult_vv.c index 39bfe547e7..9d5079f52b 100644 --- a/openair1/PHY/TOOLS/cmult_vv.c +++ b/openair1/PHY/TOOLS/cmult_vv.c @@ -27,6 +27,7 @@ #if defined(__x86_64__) || defined(__i386__) int16_t conjug[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; +int16_t conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; #define simd_q15_t __m128i #define simdshort_q15_t __m64 #elif defined(__arm__) @@ -134,3 +135,81 @@ int mult_cpx_conj_vector(int16_t *x1, return(0); } +int multadd_cpx_vector(int16_t *x1, + int16_t *x2, + int16_t *y, + uint8_t zero_flag, + uint32_t N, + int output_shift) +{ + // Multiply elementwise the complex conjugate of x1 with x2. + // x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + // We assume x1 with a dinamic of 15 bit maximum + // + // x2 - input 2 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + // We assume x2 with a dinamic of 14 bit maximum + /// + // y - output in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + // + // zero_flag - Set output (y) to zero prior to disable accumulation + // + // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; + // + // output_shift - shift to be applied to generate output + + uint32_t i; // loop counter + + simd_q15_t *x1_128; + simd_q15_t *x2_128; + simd_q15_t *y_128; +#if defined(__x86_64__) || defined(__i386__) + simd_q15_t tmp_re,tmp_im; + simd_q15_t tmpy0,tmpy1; +#elif defined(__arm__) + int32x4_t tmp_re,tmp_im; + int32x4_t tmp_re1,tmp_im1; + int16x4x2_t tmpy; + int32x4_t shift = vdupq_n_s32(-output_shift); +#endif + + x1_128 = (simd_q15_t *)&x1[0]; + x2_128 = (simd_q15_t *)&x2[0]; + y_128 = (simd_q15_t *)&y[0]; + + + // we compute 4 cpx multiply for each loop + for(i=0; i<(N>>2); i++) { +#if defined(__x86_64__) || defined(__i386__) + tmp_re = _mm_sign_epi16(*x1_128,*(__m128i*)&conjug2[0]); + tmp_re = _mm_madd_epi16(tmp_re,*x2_128); + tmp_im = _mm_shufflelo_epi16(*x1_128,_MM_SHUFFLE(2,3,0,1)); + tmp_im = _mm_shufflehi_epi16(tmp_im,_MM_SHUFFLE(2,3,0,1)); + tmp_im = _mm_madd_epi16(tmp_im,*x2_128); + tmp_re = _mm_srai_epi32(tmp_re,output_shift); + tmp_im = _mm_srai_epi32(tmp_im,output_shift); + tmpy0 = _mm_unpacklo_epi32(tmp_re,tmp_im); + //print_ints("unpack lo:",&tmpy0[i]); + tmpy1 = _mm_unpackhi_epi32(tmp_re,tmp_im); + //print_ints("unpack hi:",&tmpy1[i]); + + if (zero_flag == 1) + *y_128 = _mm_packs_epi32(tmpy0,tmpy1); + else + *y_128 = _mm_adds_epi16(*y_128,_mm_packs_epi32(tmpy0,tmpy1)); + //print_shorts("*y_128:",&y_128[i]); + +#elif defined(__arm__) + + msg("mult_cpx_vector not implemented for __arm__"); +#endif + x1_128++; + x2_128++; + y_128++; + } + + + _mm_empty(); + _m_empty(); + + return(0); +} diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/defs.h index 273822c598..8f0ae402bf 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/defs.h @@ -126,6 +126,25 @@ int mult_cpx_conj_vector(int16_t *x1, int output_shift, int madd); +/*! + Element-wise multiplication and accumulation of two complex vectors x1 and x2. + @param x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + We assume x1 with a dinamic of 15 bit maximum + @param x2 - input 2 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + We assume x2 with a dinamic of 14 bit maximum + @param y - output in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| + @param zero_flag Set output (y) to zero prior to accumulation + @param N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; + @param output_shift - shift to be applied to generate output +*/ + +int multadd_cpx_vector(int16_t *x1, + int16_t *x2, + int16_t *y, + uint8_t zero_flag, + uint32_t N, + int output_shift); + // lte_dfts.c void init_fft(uint16_t size, uint8_t logsize, From 550759231df6b7401a802a1077230928cc599710 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 18 Jan 2017 09:38:14 +0100 Subject: [PATCH 67/97] change loop limit to NB_ANTENNA_PORTS_ENB --- openair1/PHY/MODULATION/beamforming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index acf792b519..6864ca110e 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -63,7 +63,7 @@ int beam_precoding(int32_t **txdataF, // clear txdata_BF[aa][re] for each call of ue_spec_beamforming memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size)); - for (p=0; p<14; p++) { + for (p=0; pofdm_symbol_size],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15); //mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1); From adbc609bbf08a9c83bb4f6520351f9bb8a792070 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Wed, 18 Jan 2017 10:33:52 +0100 Subject: [PATCH 68/97] bugfix: reset DCI count before adding one The management of uplink failure generates a DCI to send a RA PDCCH order. It calls add_ue_spec_dci which increases DCI_pdu[CC_id]->Num_ue_spec_dci, but this was reset to 0 *after* the DCI generation. Let's reset *before*. Bug reported by Liang Yong on openair5g-user mailing list. --- openair2/LAYER2/MAC/eNB_scheduler.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index e8ed8b8f5e..d00167160f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -121,6 +121,17 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100); } + // clear DCI and BCCH contents before scheduling + for (CC_id=0; CC_idNum_common_dci = 0; + DCI_pdu[CC_id]->Num_ue_spec_dci = 0; +#ifdef Rel10 + eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0; +#endif + eNB_mac_inst[module_idP].frame = frameP; + eNB_mac_inst[module_idP].subframe = subframeP; + } + // refresh UE list based on UEs dropped by PHY in previous subframe i = UE_list->head; @@ -318,22 +329,6 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, #endif - // clear DCI and BCCH contents before scheduling - for (CC_id=0; CC_idNum_common_dci = 0; - DCI_pdu[CC_id]->Num_ue_spec_dci = 0; - - -#ifdef Rel10 - eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0; -#endif - - eNB_mac_inst[module_idP].frame = frameP; - eNB_mac_inst[module_idP].subframe = subframeP; - - - } - /* #ifndef DISABLE_SF_TRIGGER */ /* //Send subframe trigger to the controller */ /* if (mac_agent_registered[module_idP]) { */ From 773afc1490bf9c2b5bb7ecbb08052c16d997ecae Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Wed, 18 Jan 2017 13:21:07 +0100 Subject: [PATCH 69/97] TX power calibration, RX_W by default --- targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp | 2 +- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp index bd58bb7484..1482115e10 100644 --- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp +++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp @@ -213,7 +213,7 @@ int trx_lms_start(openair0_device *device){ printf("Set TX frequency %f MHz\n",device->openair0_cfg[0].tx_freq[0]/1e6); printf("Override antenna settings to: RX1_W, TXA_2"); - LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 3); + LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 2); LMS_SetAntenna(lms_device, LMS_CH_TX, 0, 2); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf index 1e4482364d..e12acef703 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.lmssdr.conf @@ -39,7 +39,7 @@ eNBs = nb_antenna_ports = 1; nb_antennas_tx = 1; nb_antennas_rx = 1; - tx_gain = 60; + tx_gain = 100; rx_gain = 111; prach_root = 0; prach_config_index = 0; @@ -50,7 +50,7 @@ eNBs = pucch_nRB_CQI = 1; pucch_nCS_AN = 0; pucch_n1_AN = 32; - pdsch_referenceSignalPower = -27; + pdsch_referenceSignalPower = -30; pdsch_p_b = 0; pusch_n_SB = 1; pusch_enable64QAM = "DISABLE"; From dce5191542309cf3e36e5196efe6eefe37302021 Mon Sep 17 00:00:00 2001 From: Tien-Thinh Nguyen Date: Wed, 18 Jan 2017 13:53:05 +0100 Subject: [PATCH 70/97] 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 1224cf44ae9c1951614a4df3db5a9153fb96fd5c Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Wed, 18 Jan 2017 14:14:07 +0100 Subject: [PATCH 71/97] switch RX to HIGH band input by default --- targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp index 1482115e10..3a9878e82b 100644 --- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp +++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp @@ -212,8 +212,8 @@ int trx_lms_start(openair0_device *device){ } printf("Set TX frequency %f MHz\n",device->openair0_cfg[0].tx_freq[0]/1e6); - printf("Override antenna settings to: RX1_W, TXA_2"); - LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 2); + printf("Override antenna settings to: RX1_H, TXA_2"); + LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 1); LMS_SetAntenna(lms_device, LMS_CH_TX, 0, 2); From b0b5cb21e53fade58af575ac2cd0794af191803e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 18 Jan 2017 15:31:04 +0100 Subject: [PATCH 72/97] Beamforming is now only done when necessary. This patch is based on one from enhancement-10-harmony. --- openair1/PHY/INIT/lte_init.c | 1 + openair1/PHY/MODULATION/defs.h | 2 +- openair1/PHY/MODULATION/ofdm_mod.c | 22 +++++++++++----------- openair1/PHY/defs.h | 2 ++ openair1/SIMULATION/LTE_PHY/dlsim.c | 6 ++++-- targets/RT/USER/lte-enb.c | 20 ++++++++++++++------ 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index accc54af54..4d927dc5d3 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -684,6 +684,7 @@ void phy_config_dedicated_eNB(uint8_t Mod_id, break; case AntennaInfoDedicated__transmissionMode_tm7: lte_gold_ue_spec_port5(eNB->lte_gold_uespec_port5_table[0],eNB->frame_parms.Nid_cell,rnti); + eNB->do_precoding = 1; eNB->transmission_mode[UE_id] = 7; break; default: diff --git a/openair1/PHY/MODULATION/defs.h b/openair1/PHY/MODULATION/defs.h index 6937db6d9b..da599114a9 100644 --- a/openair1/PHY/MODULATION/defs.h +++ b/openair1/PHY/MODULATION/defs.h @@ -82,7 +82,7 @@ void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRA void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); -void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); +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); void remove_7_5_kHz(PHY_VARS_eNB *phy_vars_eNB,uint8_t subframe); diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 74037b4a6e..8e09cea1ec 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -285,16 +285,16 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne } // OFDM modulation for each symbol -void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms) +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]; + 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); + 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++) { @@ -302,13 +302,13 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne //printf("do_OFDM_mod_l, slot=%d, l=%d, NUMBER_OF_OFDM_CARRIERS=%d,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES=%d\n",next_slot, l,NUMBER_OF_OFDM_CARRIERS,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,1); - beam_precoding(txdataF,txdataF_BF,frame_parms,eNB_common_vars->beam_weights[eNB_id],next_slot,l,aa); + if (do_precoding==1) beam_precoding(txdataF,txdataF_BF,frame_parms,eNB_common_vars->beam_weights[eNB_id],next_slot,l,aa); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,0); //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/PHY/defs.h b/openair1/PHY/defs.h index d462fe58cb..0bc7c6e1c1 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -415,6 +415,8 @@ typedef struct PHY_VARS_eNB_s { int single_thread_flag; openair0_rf_map rf_map; int abstraction_flag; + // indicator for precoding function (eNB,3GPP_eNB_BBU) + int do_precoding; 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/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index f9a8acfa85..0682308ab7 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -2409,12 +2409,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 a3d6d96e03..331a2b5fe1 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -296,16 +296,18 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,1); do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, - 0, - subframe<<1, - &phy_vars_eNB->frame_parms); + 0, + subframe<<1, + &phy_vars_eNB->frame_parms, + &phy_vars_eNB->do_precoding); // if S-subframe generate first slot only if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) { do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, - 0, - 1+(subframe<<1), - &phy_vars_eNB->frame_parms); + 0, + 1+(subframe<<1), + &phy_vars_eNB->frame_parms, + &phy_vars_eNB->do_precoding); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0); @@ -1637,6 +1639,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst case NGFI_RRU_IF5: eNB->do_prach = NULL; eNB->fep = eNB_fep_rru_if5; + eNB->do_precoding = 0; eNB->td = NULL; eNB->te = NULL; eNB->proc_uespec_rx = NULL; @@ -1661,6 +1664,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst } break; case NGFI_RRU_IF4p5: + eNB->do_precoding = 0; eNB->do_prach = do_prach; eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; eNB->td = NULL; @@ -1690,6 +1694,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_antennas_tx==eNB->frame_parms.nb_antenna_ports_eNB; 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; @@ -1710,6 +1715,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_antennas_tx==eNB->frame_parms.nb_antenna_ports_eNB; 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; @@ -1742,6 +1748,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst } break; case NGFI_RCC_IF4p5: + eNB->do_precoding = 0; eNB->do_prach = do_prach; eNB->fep = NULL; eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; @@ -1765,6 +1772,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst break; case NGFI_RAU_IF4p5: + eNB->do_precoding = 0; eNB->do_prach = do_prach; eNB->fep = NULL; From 0695828e4c67707fa8ded86f0d2cde37a6ce388e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 18 Jan 2017 16:43:02 +0100 Subject: [PATCH 73/97] some fixes --- .../CONF/enb.band4.tm1.usrpb210.conf | 14 ++++++++++---- targets/RT/USER/lte-enb.c | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band4.tm1.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band4.tm1.usrpb210.conf index 853db14393..4004b5faec 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band4.tm1.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band4.tm1.usrpb210.conf @@ -17,12 +17,15 @@ eNBs = mobile_country_code = "208"; - mobile_network_code = "93"; + mobile_network_code = "92"; ////////// Physical parameters: component_carriers = ( { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; frame_type = "FDD"; tdd_config = 3; tdd_config_s = 0; @@ -35,6 +38,7 @@ eNBs = Nid_cell_mbsfn = 0; nb_antennas_tx = 1; nb_antennas_rx = 1; + nb_antenna_ports = 1; tx_gain = 90; rx_gain = 128; prach_root = 0; @@ -97,6 +101,8 @@ eNBs = ue_TimersAndConstants_t311 = 10000; ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; } ); @@ -131,7 +137,7 @@ eNBs = }; ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.12.11"; + mme_ip_address = ( { ipv4 = "192.168.12.70"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -141,10 +147,10 @@ eNBs = NETWORK_INTERFACES : { ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.150/24"; ENB_INTERFACE_NAME_FOR_S1U = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.150/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 331a2b5fe1..52688ced49 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1694,7 +1694,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_antennas_tx==eNB->frame_parms.nb_antenna_ports_eNB; + eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; 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; @@ -1715,7 +1715,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_antennas_tx==eNB->frame_parms.nb_antenna_ports_eNB; + eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; 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 e0c74791226f8074219099fde184371f3d10fe26 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 19 Jan 2017 09:32:29 +0100 Subject: [PATCH 74/97] and one more fix --- targets/RT/USER/lte-enb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 52688ced49..5889b908c2 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -288,7 +288,6 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti; - if ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_DL)|| ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) { // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); @@ -299,7 +298,7 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) 0, subframe<<1, &phy_vars_eNB->frame_parms, - &phy_vars_eNB->do_precoding); + phy_vars_eNB->do_precoding); // if S-subframe generate first slot only if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) { @@ -307,7 +306,7 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) 0, 1+(subframe<<1), &phy_vars_eNB->frame_parms, - &phy_vars_eNB->do_precoding); + phy_vars_eNB->do_precoding); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0); From 05d02c43eced4d5ee8392b1d5692403916a026c8 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 19 Jan 2017 09:49:39 +0100 Subject: [PATCH 75/97] remove annoying logging (dump_CCE_table) --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index ce08bc5408..7f81fa906e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1096,7 +1096,7 @@ try_again: 1<dci_alloc[j].L, nCCE,nCCE_max,DCI_pdu->num_pdcch_symbols); } - dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,dci_alloc->L); + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,dci_alloc->L); goto failed; } From 38b387794e43ae8af46bc32cf792400328511be9 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 19 Jan 2017 09:57:43 +0100 Subject: [PATCH 76/97] hack in RLC AM to avoid a race Here is the problem: UE comes. SRB2 is configured via message to RRC. At some point the RLC AM is created but not configured yet. At this moment (I think) MAC calls mac_rlc_status_ind which calls this function. But the init was not finished yet and we have a crash below when testing mem_block != NULL. The "solution" is to test if rlc->input_sdus is NULL. This is a very dirty hack. I would say the solution is to use proper locking mechanism because RLC is used by two threads: PHY/MAC on one hand and RRC on another hand (I think). --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 1d93055487..4051a88ef2 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -557,6 +557,15 @@ rlc_am_mac_status_indication ( status_resp.head_sdu_is_segmented = 0; status_resp.rlc_info.rlc_protocol_state = rlc->protocol_state; + /* TODO: remove this hack. Problem is: there is a race. + * UE comes. SRB2 is configured via message to RRC. + * At some point the RLC AM is created but not configured yet. + * At this moment (I think) MAC calls mac_rlc_status_ind + * which calls this function. But the init was not finished yet + * and we have a crash below when testing mem_block != NULL. + */ + if (rlc->input_sdus == NULL) return status_resp; + if (rlc->last_frame_status_indication != ctxt_pP->frame) { rlc_am_check_timer_poll_retransmit(ctxt_pP, rlc); rlc_am_check_timer_reordering(ctxt_pP, rlc); From 5933f21882d95ccfe5ea1420df05937615d8c2cd Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 19 Jan 2017 10:00:19 +0100 Subject: [PATCH 77/97] hack to avoid zombie UEs in the MAC layer Here is the problem: Sometimes the UE has no PHY context but is still present in the MAC with 'ul_failure_timer' = 0 and 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's start an UL out of sync procedure in this case. The root cause of this problem has to be found and corrected. In the meantime, this hack... This has to be redone at some point. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index ec43c2434b..6e744a5228 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -762,8 +762,25 @@ void schedule_ulsch_rnti(module_id_t module_idP, break; } } - if (drop_ue == 1) + if (drop_ue == 1) { + /* TODO: this is a hack. Sometimes the UE has no PHY context but + * is still present in the MAC with 'ul_failure_timer' = 0 and + * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's + * start an UL out of sync procedure in this case. + * The root cause of this problem has to be found and corrected. + * In the meantime, this hack... + */ + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + // inform RRC of failure and clear timer + mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti); + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=1; + } continue; + } // loop over all active UL CC_ids for this UE for (n=0; nnumactiveULCCs[UE_id]; n++) { From 27a1101a5822aa63828409d33af55be7bac0a6ae Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Thu, 19 Jan 2017 12:44:20 +0100 Subject: [PATCH 78/97] add support for RAN/radio resource slicing through flexran --- openair2/LAYER2/MAC/defs.h | 3 + openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 141 +++++- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 408 ++++++++++++++++-- 3 files changed, 511 insertions(+), 41 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 15c0f3fb0e..63501128ef 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -145,6 +145,9 @@ /*!\brief minimum MAC data needed for transmitting 1 min RLC PDU size + 1 byte MAC subHeader */ #define MIN_MAC_HDR_RLC_SIZE (1 + MIN_RLC_PDU_SIZE) +/*!\brief maximum number of slices / groups */ +#define MAX_NUM_SLICES 4 + /* * eNB part */ diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index d661b90a20..6757500dc2 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -21,7 +21,7 @@ /*! \file flexran_agent_mac_proto.h * \brief MAC functions for FlexRAN agent - * \author Xenofon Foukas + * \author Xenofon Foukas and Navid Nikaein * \date 2016 * \email: x.foukas@sms.ed.ac.uk * \version 0.1 @@ -36,6 +36,145 @@ #include "header.pb-c.h" #include "flexran.pb-c.h" +/* + * slice specific scheduler + */ +typedef void (*slice_scheduler)(module_id_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); + + + +/* + * top level flexran scheduler used by the eNB scheduler + */ +void flexran_schedule_ue_spec_default(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); +/* + * slice specific scheduler for embb + */ +void +flexran_schedule_ue_spec_embb(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); +/* + * slice specific scheduler for urllc + */ +void +flexran_schedule_ue_spec_urllc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); + +/* + * slice specific scheduler for mmtc + */ +void +flexran_schedule_ue_spec_mmtc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); +/* + * slice specific scheduler for best effort traffic + */ +void +flexran_schedule_ue_spec_be(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); + +/* + * common flexran scheduler function + */ +void +flexran_schedule_ue_spec_common(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info); + +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, + int total_rbs); + +int flexran_slice_member(int UE_id, + int slice_id); + +int flexran_slice_maxmcs(int slice_id) ; + +void _store_dlsch_buffer (module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframeP); + + +void _assign_rbs_required (module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframe, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], + int min_rb_unit[MAX_NUM_CCs]); + +int _maxround(module_id_t Mod_id, + uint16_t rnti, + int frame, + sub_frame_t subframe, + uint8_t ul_flag ); + +int _maxcqi(module_id_t Mod_id, + int32_t UE_id); + +void _sort_UEs (module_id_t Mod_idP, + int frameP, + sub_frame_t subframeP); + +void _dlsch_scheduler_pre_processor (module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag); + +void _dlsch_scheduler_pre_processor_reset (int module_idP, + int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); + +void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); + /* * Default scheduler used by the eNB agent */ diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 7f34cbb28f..3af246a5d5 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -56,6 +56,7 @@ #include "header.pb-c.h" #include "flexran.pb-c.h" #include "flexran_agent_mac.h" +#include #include "SIMULATION/TOOLS/defs.h" // for taus @@ -65,8 +66,67 @@ #define ENABLE_MAC_PAYLOAD_DEBUG +/** + * Local variables to support slicing + * + */ + + +/*!\brief UE ULSCH scheduling states*/ +typedef enum { + MIN_SLICE_STRATEGY = 0, + SLICE_MASK, + UEID_TO_SLICEID, + MAX_SLICE_STRATEGY +} SLICING_STRATEGY; + +// this assumes a max of of 16 UE per eNB/CC +#define SLICE0_MASK 0x000f +#define SLICE1_MASK 0x00f0 +#define SLICE2_MASK 0x0f00 +#define SLICE3_MASK 0xf000 + + +// number of active slices for past and current time +int n_active_slices = 1; +int n_active_slices_current = 1; + +// ue to slice mapping +int slicing_strategy = UEID_TO_SLICEID; +int slicing_strategy_current = UEID_TO_SLICEID; + +// RB share for each slice for past and current time +float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float total_slice_percentage = 0; + +// MAX MCS for each slice for past and current time +int slice_maxmcs[MAX_NUM_SLICES] = {28, 28, 28, 28}; +int slice_maxmcs_current[MAX_NUM_SLICES] = {28, 28, 28, 28}; + +int update_dl_scheduler[MAX_NUM_SLICES] = {1, 0, 0, 0}; +int update_dl_scheduler_current[MAX_NUM_SLICES] = {1, 0, 0, 0}; + +// name of available scheduler +char *dl_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_spec_embb", + "flexran_schedule_ue_spec_urllc", + "flexran_schedule_ue_spec_mmtc", + "flexran_schedule_ue_spec_be" // best effort +}; + +// pointer to the slice specific scheduler +slice_scheduler slice_sched[MAX_NUM_SLICES] = {0}; + + +/** + * preprocessor functions for scheduling + * + */ + + // This function stores the downlink buffer for all the logical channels void _store_dlsch_buffer (module_id_t Mod_id, + int slice_id, frame_t frameP, sub_frame_t subframeP) { @@ -78,7 +138,10 @@ void _store_dlsch_buffer (module_id_t Mod_id, UE_TEMPLATE *UE_template; for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + UE_template = &UE_list->UE_template[UE_PCCID(Mod_id,UE_id)][UE_id]; // clear logical channel interface variables @@ -114,8 +177,8 @@ void _store_dlsch_buffer (module_id_t Mod_id, */ if (UE_template->dl_buffer_info[i]>0) LOG_D(MAC, - "[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", - Mod_id, frameP, subframeP, UE_id, + "[eNB %d][SLICE %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", + Mod_id, slice_id,frameP, subframeP, UE_id, i, UE_template->dl_pdus_in_buffer[i],UE_template->dl_buffer_info[i], UE_template->dl_buffer_head_sdu_creation_time[i], UE_template->dl_buffer_head_sdu_remaining_size_to_send[i], @@ -141,10 +204,12 @@ void _store_dlsch_buffer (module_id_t Mod_id, // This function returns the estimated number of RBs required by each UE for downlink scheduling void _assign_rbs_required (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - int min_rb_unit[MAX_NUM_CCs]) + int slice_id, + frame_t frameP, + sub_frame_t subframe, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], + int min_rb_unit[MAX_NUM_CCs]) { @@ -157,6 +222,10 @@ void _assign_rbs_required (module_id_t Mod_id, // clear rb allocations across all CC_ids for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + pCCid = UE_PCCID(Mod_id,UE_id); rnti = UE_list->UE_template[pCCid][UE_id].rnti; @@ -198,7 +267,8 @@ void _assign_rbs_required (module_id_t Mod_id, } TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); - + nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage[slice_id], + flexran_get_N_RB_DL(Mod_id, CC_id)); LOG_D(MAC,"[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, nb_rbs_required[CC_id][UE_id],eNB_UE_stats[CC_id]->dlsch_mcs1,TBS); @@ -207,17 +277,17 @@ void _assign_rbs_required (module_id_t Mod_id, while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - if (nb_rbs_required[CC_id][UE_id] > flexran_get_N_RB_DL(Mod_id, CC_id)) { - TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1, flexran_get_N_RB_DL(Mod_id, CC_id)); - nb_rbs_required[CC_id][UE_id] = flexran_get_N_RB_DL(Mod_id, CC_id); + if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { + TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1, nb_rbs_allowed_slice[CC_id][slice_id]); + nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; break; } TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); } // end of while - LOG_D(MAC,"[eNB %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", - Mod_id, frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, eNB_UE_stats[CC_id]->dlsch_mcs1); + LOG_D(MAC,"[eNB %d][SLICE %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", + Mod_id, slice_id,frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, eNB_UE_stats[CC_id]->dlsch_mcs1); } } } @@ -391,6 +461,7 @@ void _dlsch_scheduler_pre_processor_reset (int module_idP, int N_RBG, uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) { int i,j; @@ -413,7 +484,8 @@ void _dlsch_scheduler_pre_processor_reset (int module_idP, ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; ue_sched_ctl->dl_pow_off[CC_id] = 2; nb_rbs_required_remaining[CC_id][UE_id] = 0; - + for (i=0; i0) // If this CC is allocated for MBSFN skip it here @@ -503,7 +578,8 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, UE_id = i; // Initialize scheduling information for all active UEs - + //if (flexran_slice_member(UE_id, slice_id) == 0) + //continue; _dlsch_scheduler_pre_processor_reset(Mod_id, UE_id, CC_id, @@ -512,6 +588,7 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, N_RBG[CC_id], nb_rbs_required, nb_rbs_required_remaining, + nb_rbs_allowed_slice, rballoc_sub, MIMO_mode_indicator); @@ -519,10 +596,10 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, } // Store the DLSCH buffer for each logical channel - _store_dlsch_buffer (Mod_id,frameP,subframeP); + _store_dlsch_buffer (Mod_id,slice_id,frameP,subframeP); // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - _assign_rbs_required (Mod_id,frameP,subframeP,nb_rbs_required,min_rb_unit); + _assign_rbs_required (Mod_id,slice_id, frameP,subframeP,nb_rbs_required,nb_rbs_allowed_slice,min_rb_unit); // Sorts the user on the basis of dlsch logical channel buffer and CQI _sort_UEs (Mod_id,frameP,subframeP); @@ -537,7 +614,10 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; UE_id = i; - + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + // if there is no available harq_process, skip the UE if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) continue; @@ -545,6 +625,7 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { CC_id = UE_list->ordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); average_rbs_per_user[CC_id]=0; @@ -575,8 +656,8 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; - } else if( (min_rb_unit[CC_id] * total_ue_count) <= (frame_parms[CC_id]->N_RB_DL) ) { - average_rbs_per_user[CC_id] = (uint16_t) floor(frame_parms[CC_id]->N_RB_DL/total_ue_count); + } else if( (min_rb_unit[CC_id] * total_ue_count) <= nb_rbs_allowed_slice[CC_id][slice_id] ) { + average_rbs_per_user[CC_id] = (uint16_t) floor(nb_rbs_allowed_slice[CC_id][slice_id]/total_ue_count); } else { average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE } @@ -587,7 +668,10 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, // extend nb_rbs_required to capture per LCID RB required for(i=UE_list->head; i>=0; i=UE_list->next[i]) { rnti = UE_RNTI(Mod_id,i); - + + if (flexran_slice_member(i, slice_id) == 0) + continue; + for (ii=0; iiordered_CCids[ii][i]; @@ -607,6 +691,10 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, for(r1=0; r1<2; r1++) { for(i=UE_list->head; i>=0; i=UE_list->next[i]) { + + if (flexran_slice_member(i, slice_id) == 0) + continue; + for (ii=0; iiordered_CCids[ii][i]; @@ -632,8 +720,11 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, if (total_ue_count > 0 ) { for(i=UE_list->head; i>=0; i=UE_list->next[i]) { UE_id = i; - - for (ii=0; iiordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); @@ -672,6 +763,9 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, for(i=UE_list->head; i>=0; i=UE_list->next[i]) { UE_id = i; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; for (ii=0; iiordered_CCids[ii][UE_id]; @@ -688,7 +782,8 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, } //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC,"Total RBs allocated for UE%d = %d\n",UE_id,ue_sched_ctl->pre_nb_available_rbs[CC_id]); + LOG_D(MAC,"[eNB %d][SLICE %d] Total RBs allocated for UE%d = %d\n", + Mod_id, slice_id, UE_id,ue_sched_ctl->pre_nb_available_rbs[CC_id]); } } } @@ -696,8 +791,11 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, #define SF05_LIMIT 1 +/* + * Main scheduling functions to support slicing + * + */ -//------------------------------------------------------------------------------ void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, @@ -705,6 +803,224 @@ flexran_schedule_ue_spec_default(mid_t mod_id, int *mbsfn_flag, Protocol__FlexranMessage **dl_info) //------------------------------------------------------------------------------ +{ + int i=0; + + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + + for (i = 0; i < n_active_slices; i++) { + + // Load any updated functions + if (update_dl_scheduler[i] > 0 ) { + slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); + update_dl_scheduler[i] = 0; + update_dl_scheduler_current[i] = 0; + slice_percentage_current[i]= slice_percentage[i]; + total_slice_percentage+=slice_percentage[i]; + LOG_N(MAC,"update dl scheduler slice %d\n", i); + } + + // check if the number of slices has changed, and log + if (n_active_slices_current != n_active_slices ){ + if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current, n_active_slices); + n_active_slices_current = n_active_slices; + } else { + LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); + n_active_slices = n_active_slices_current; + } + } + + // check if the slice rb share has changed, and log the console + if (slice_percentage_current[i] != slice_percentage[i]){ + if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ + if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { + total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; + LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + slice_percentage_current[i] = slice_percentage[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", + mod_id,i, + total_slice_percentage, + total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], + slice_percentage[i],slice_percentage_current[i]); + slice_percentage[i]= slice_percentage_current[i]; + + } + } else { + LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); + slice_percentage[i]= slice_percentage_current[i]; + + } + } + + // check if the slice max MCS, and log the console + if (slice_maxmcs_current[i] != slice_maxmcs[i]){ + if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ + LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); + slice_maxmcs_current[i] = slice_maxmcs[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_percentage[i],slice_percentage[i]); + slice_maxmcs[i]= slice_maxmcs_current[i]; + } + } + + // check if a new scheduler, and log the console + if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, dl_scheduler_type[i]); + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + } + + // Run each enabled slice-specific schedulers one by one + //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); + slice_sched[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + + } + +} + +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs){ + return (uint16_t) floor(rb_percentage * total_rbs); +} + +int flexran_slice_maxmcs(int slice_id) { + return slice_maxmcs[slice_id]; +} + +int flexran_slice_member(int UE_id, int slice_id){ + // group membership definition + int slice_member = 0 ; + + if ((slice_id < 0) || (slice_id > n_active_slices)) + LOG_W(MAC,"out of range slice id %d\n",slice_id); + + switch (slicing_strategy) { + case SLICE_MASK: + switch (slice_id){ + case 0: + if (SLICE0_MASK&UE_id){ + slice_member=1; + } + break; + case 1: + if (SLICE1_MASK&UE_id){ + slice_member=1; + } + break; + case 2: + if (SLICE2_MASK&UE_id){ + slice_member=1; + } + break; + case 3: + if (SLICE3_MASK&UE_id){ + slice_member=1; + } + break; + default : + LOG_W(MAC,"unknown slice_id %d\n", slice_id); + break; + + } + break; + case UEID_TO_SLICEID: + default: + if ((UE_id % n_active_slices) == slice_id){ + slice_member= 1; // this ue is a member of this slice + } + break; + } + + return slice_member; +} +/* more aggressive rb and mcs allocation with medium priority and the traffic qci */ +void +flexran_schedule_ue_spec_embb(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) + +{ + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, + subframe, + mbsfn_flag, + dl_info); + +} +/* more conservative mcs allocation with high priority and the traffic qci */ +void +flexran_schedule_ue_spec_urllc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) + +{ + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, + subframe, + mbsfn_flag, + dl_info); + +} +/* constant rb allocation with low mcs with low priority and given the UE capabilities */ +void +flexran_schedule_ue_spec_mmtc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) + +{ + + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, + subframe, + mbsfn_flag, + dl_info); + +} +/* regular rb and mcs allocation with low priority */ +void +flexran_schedule_ue_spec_be(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) + +{ + + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, + subframe, + mbsfn_flag, + dl_info); + +} + +//------------------------------------------------------------------------------ +void +flexran_schedule_ue_spec_common(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) +//------------------------------------------------------------------------------ { uint8_t CC_id; int UE_id; @@ -776,10 +1092,11 @@ flexran_schedule_ue_spec_default(mid_t mod_id, start_meas(&eNB->schedule_dlsch_preprocessor); _dlsch_scheduler_pre_processor(mod_id, - frame, - subframe, - N_RBG, - mbsfn_flag); + slice_id, + frame, + subframe, + N_RBG, + mbsfn_flag); stop_meas(&eNB->schedule_dlsch_preprocessor); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); @@ -793,6 +1110,9 @@ flexran_schedule_ue_spec_default(mid_t mod_id, rnti = flexran_get_ue_crnti(mod_id, UE_id); ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + if (rnti==NOT_A_RNTI) { LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n", UE_id,UE_list->num_UEs); // mac_xface->macphy_exit("Cannot find rnti for UE_id"); @@ -840,7 +1160,7 @@ flexran_schedule_ue_spec_default(mid_t mod_id, flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); sdu_length_total=0; mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - + mcs = cmin(mcs,flexran_slice_maxmcs(slice_id)); #ifdef EXMIMO if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { @@ -1372,12 +1692,20 @@ flexran_schedule_ue_spec_default(mid_t mod_id, } // CC_id loop // Add all the dl_data elements to the flexran message - (*dl_info)->dl_mac_config_msg->n_dl_ue_data = num_ues_added; - (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) malloc(sizeof(Protocol__FlexDlData *) * num_ues_added); - for (i = 0; i < num_ues_added; i++) { - (*dl_info)->dl_mac_config_msg->dl_ue_data[i] = dl_data[i]; + int offset = (*dl_info)->dl_mac_config_msg->n_dl_ue_data; + (*dl_info)->dl_mac_config_msg->n_dl_ue_data += num_ues_added; + if ( num_ues_added > 0 ){ + (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) realloc( (*dl_info)->dl_mac_config_msg->dl_ue_data, + sizeof(Protocol__FlexDlData *) * ((*dl_info)->dl_mac_config_msg->n_dl_ue_data)); + if ((*dl_info)->dl_mac_config_msg->dl_ue_data == NULL ){ + LOG_E(MAC, "Request for memory reallocation failed\n"); + return; + } + for (i = 0; i < num_ues_added; i++) { + (*dl_info)->dl_mac_config_msg->dl_ue_data[offset+i] = dl_data[i]; + } } - + stop_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); } From 390085c377d286db47f0262204d93c1ea4cefb94 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 19 Jan 2017 12:47:50 +0100 Subject: [PATCH 79/97] remove printing of UE capabilities on stdout Modern UEs have very long UE capabilities. It disrupts realtime behaviour of the modem. Let's put a simple log message indicating we got the UE capabilities. --- openair2/RRC/LITE/rrc_eNB.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 1ed4da9b27..d37741b40f 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -96,7 +96,7 @@ #if defined(FLEXRAN_AGENT_SB_IF) #include "flexran_agent_extern.h" #endif -#define XER_PRINT +//#define XER_PRINT #ifdef PHY_EMUL extern EMULATION_VARS *Emul_vars; @@ -4786,6 +4786,7 @@ rrc_eNB_decode_dcch( #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg); #endif + LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); dec_rval = uper_decode(NULL, &asn_DEF_UE_EUTRA_Capability, (void **)&UE_EUTRA_Capability, @@ -4796,7 +4797,7 @@ rrc_eNB_decode_dcch( choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. array[0]->ueCapabilityRAT_Container.size, 0, 0); //#ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability); + //xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability); //#endif #if defined(ENABLE_USE_MME) From 2c578f350aad32e36d39f736bec2424fc419f3e4 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 19 Jan 2017 17:23:15 +0100 Subject: [PATCH 80/97] remove XER printing in asn1_msg.c, too verbose --- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 5f9a8e0e2a..b4290e8b9d 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -99,7 +99,7 @@ int errno; # endif #endif -#define XER_PRINT +//#define XER_PRINT extern Enb_properties_array_t enb_properties; typedef struct xer_sprint_string_s { From 56241235cf1b1c5c51d8963700a74393d35ae051 Mon Sep 17 00:00:00 2001 From: "Raymond.Knopp" Date: Fri, 20 Jan 2017 08:44:41 +0100 Subject: [PATCH 81/97] 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 }; From 2a1d1134e91bccd9de37cf89f5461dcba7755aa6 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 14:54:19 +0100 Subject: [PATCH 82/97] log an error if UE is -1 in rrc_mac_config_req --- openair2/LAYER2/MAC/config.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 2e76735fa7..b5d613e4ae 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -195,10 +195,14 @@ rrc_mac_config_req( } } else { - if (logicalChannelConfig) - UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; - else - UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0; + if (UE_id == -1) { + LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + } else { + if (logicalChannelConfig) + UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; + else + UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0; + } } } @@ -296,7 +300,10 @@ rrc_mac_config_req( if (physicalConfigDedicated != NULL) { if (eNB_flagP==1) { - mac_xface->phy_config_dedicated_eNB(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated); + if (UE_id == -1) + LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + else + mac_xface->phy_config_dedicated_eNB(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated); } else { mac_xface->phy_config_dedicated_ue(Mod_idP,0,eNB_index,physicalConfigDedicated); UE_mac_inst[Mod_idP].physicalConfigDedicated=physicalConfigDedicated; // for SR proc @@ -308,7 +315,10 @@ rrc_mac_config_req( if (sCellToAddMod_r10 != NULL) { if (eNB_flagP==1) { - mac_xface->phy_config_dedicated_scell_eNB(Mod_idP,UE_RNTI(Mod_idP,UE_id),sCellToAddMod_r10,1); + if (UE_id == -1) + LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + else + mac_xface->phy_config_dedicated_scell_eNB(Mod_idP,UE_RNTI(Mod_idP,UE_id),sCellToAddMod_r10,1); } else { //#warning "phy_config_dedicated_scell_ue is empty" From c33afccb1be0f0a5ca96433bb6d77cf356d47095 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 14:57:28 +0100 Subject: [PATCH 83/97] bugfix: logging was done after modification of values It resulted in wrong log message, leading to complicated debugging. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 6e744a5228..d09111290d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -904,6 +904,12 @@ void schedule_ulsch_rnti(module_id_t module_idP, T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(TBS), T_INT(ndi)); + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, + first_rb[CC_id],rb_table[rb_table_index], + rb_table_index,TBS,harq_pid); + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) // increment for next UE allocation first_rb[CC_id]+=rb_table[rb_table_index]; @@ -913,12 +919,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, if (UE_id == UE_list->head) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,TBS,harq_pid); - // adjust total UL buffer status by TBS, wait for UL sdus to do final update LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,TBS); if (UE_template->ul_total_buffer > TBS) From 89445da9ebb3f136e4b730ec339616e3cc308a1f Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 14:59:24 +0100 Subject: [PATCH 84/97] attempting at fixing RRC RRC does not work very well when one UE goes away and comes back in some situations. This commit is an attempt at making things work better. It is probably not the end of the story. --- openair2/RRC/LITE/rrc_eNB.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index d37741b40f..8b5b012ff1 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -4191,9 +4191,11 @@ rrc_eNB_decode_ccch( * the current one must be removed from MAC/PHY (zombie UE) */ if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { -//#warning "TODO: random_exist: remove UE from MAC/PHY (how?)" - // AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)"); + LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", + ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti); + rrc_mac_remove_ue(ctxt_pP->module_id, ctxt_pP->rnti); ue_context_p = NULL; + return 0; } else { ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); } @@ -4204,9 +4206,8 @@ rrc_eNB_decode_ccch( m_tmsi_t m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI); random_value = (((uint64_t)mme_code) << 32) | m_tmsi; if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) { - - //#warning "TODO: stmsi_exist: remove UE from MAC/PHY (how?)" LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti); + rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti); stmsi_received=1; /* replace rnti in the context */ /* for that, remove the context from the RB tree */ @@ -4218,8 +4219,6 @@ rrc_eNB_decode_ccch( /* reset timers */ ue_context_p->ue_context.ul_failure_timer = 0; ue_context_p->ue_context.ue_release_timer = 0; - // AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)"); - // ue_context_p = NULL; } else { LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi); ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); @@ -4230,7 +4229,8 @@ rrc_eNB_decode_ccch( ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code; ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi; } else { - break; + /* TODO: do we have to break here? */ + //break; } } From a5d5a21ddb5b467886954c99648a7cf77b1727b0 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:01:51 +0100 Subject: [PATCH 85/97] "fix" handling of UE_id in RA. What if it's -1? Is it possible? We catch the case and abort. We may do a proper fix if the case happen. I don't think it will, but who knows... --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index e24281b89a..195c78c538 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -73,7 +73,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un unsigned char i,harq_pid,round; int16_t rrc_sdu_length; unsigned char lcid,offset; - module_id_t UE_id= UE_INDEX_INVALID; + int UE_id = -1; unsigned short TBsize = -1; unsigned short msg4_padding,msg4_post_padding,msg4_header; uint8_t *vrb_map; @@ -266,6 +266,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un // check for Msg4 Message UE_id = find_UE_id(module_idP,RA_template->rnti); + if (UE_id == -1) { printf("%s:%d:%s: FATAL ERROR\n", __FILE__, __LINE__, __FUNCTION__); abort(); } if (Is_rrc_registered == 1) { From c1fee62473084fe6b75d56172c4954d20622992d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:05:28 +0100 Subject: [PATCH 86/97] RA: fix allocation of RA process A RA process is not available if and RA_template[i].wait_ack_Msg4 != 0 We can have RA_active==FALSE and wait_ack_Msg4==1, in which case the RA process is in use and cannot be reassigned. --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 195c78c538..8ff409978e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -747,7 +747,8 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,0); for (i=0; i Date: Fri, 20 Jan 2017 15:09:05 +0100 Subject: [PATCH 87/97] fix: better creation of RNTI The previous version was calling taus(), which may return any value in [0..65535]. The new version restricts it to [1024..59999] (arbitrary values, big enough, and in the valid range). It also checks that the new RNTI is not already present in the MAC. I think we should also check that it's not used by a RA process. The "loop" thing may not be the best solution either. To be refined. --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 8ff409978e..63109a4c0f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -749,13 +749,24 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t for (i=0; i= 1024 && RA_template[i].rnti < 60000)); + if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); } RA_template[i].RA_rnti = 1+subframeP+(10*f_id); RA_template[i].preamble_index = preamble_index; LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n", From 0d3fa211878f67198c6760ba37830702f03a3d64 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:11:40 +0100 Subject: [PATCH 88/97] add a LOG in RA --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 63109a4c0f..e046c085e1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -776,6 +776,8 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t return; } } + + LOG_E(MAC,"[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,preamble_index); } void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, rnti_t rnti) From c3c2b774d631fe3cba4898bb8ef860b1021d968d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:15:58 +0100 Subject: [PATCH 89/97] bugfix: do not get pCC_id if UE_id is invalid --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7f81fa906e..71cbb36ce9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -288,7 +288,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; int UE_id = find_UE_id(mod_idP,rntiP); - int pCC_id = UE_PCCID(mod_idP,UE_id); + int pCC_id; if (UE_id == -1) { LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP); @@ -296,6 +296,8 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) return 0; } + pCC_id = UE_PCCID(mod_idP,UE_id); + LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); dump_ue_list(UE_list,0); From c824eea0745e19b0f0a2604e67aaa4cb47ff3707 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:21:37 +0100 Subject: [PATCH 90/97] better (maybe) freeing of RA process when an UE is removed from MAC The RA process may be in the state: RA_active == FALSE and wait_ack_Msg4 == 1 Testing only the rnti should be enough, if everything else works properly. Also, don't break, just in case. (Not sure it makes a difference.) --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 71cbb36ce9..3cf36eaa8d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -365,8 +365,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) RA_TEMPLATE *RA_template; for (i=0;iRA_active == TRUE) && - (RA_template->rnti == rntiP)){ + if (RA_template->rnti == rntiP){ RA_template->RA_active=FALSE; RA_template->generate_rar=0; RA_template->generate_Msg4=0; @@ -374,7 +373,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) RA_template->timing_offset=0; RA_template->RRC_timer=20; RA_template->rnti = 0; - break; + //break; } } if (ret == 0) { From da75a078709f1952554759110c07d824b7e32fbf Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:36:58 +0100 Subject: [PATCH 91/97] rewrite sort_UE for UL and DL and adapt the rest to the change The previous version did not seem to work properly with several UEs. I too often ended up with a list 'next' where next[i] = i, leading to an infinite loop, crashing the processing. The sorting functions were hard to understand and too slow anyway (O(n*n)). We now use qsort_r and comparison functions, that should define the same order as the previous version. One important point is that the "next" lists and the "head" variable are now considered invalid before calling sort_UE. So all the code (coming before sort_UE) that looped using those variables has been rewritten to loop over all possible UEs and the first instruction of the loop is to exit the loop if the UE is not 'active'. There is room for improvement here. We will reintroduce a list of some kind at some point. Let's first have something that works and then optimize. Today NUMBER_OF_UE_MAX is 16, that's not a big deal. Consequently, the add_new_ue and rrc_mac_remove_ue have also been rewritten, hopefully for the better. This commit is not a basic work and may introduce some problems. --- openair2/LAYER2/MAC/eNB_scheduler.c | 10 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 + .../LAYER2/MAC/eNB_scheduler_primitives.c | 81 +---- openair2/LAYER2/MAC/pre_processor.c | 291 ++++++++++++++++-- 4 files changed, 283 insertions(+), 101 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index d00167160f..023d01d656 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -99,7 +99,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, int result; #endif DCI_PDU *DCI_pdu[MAX_NUM_CCs]; - int CC_id,i,next_i; + int CC_id,i; //,next_i; UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; rnti_t rnti; void *DLSCH_dci=NULL; @@ -133,17 +133,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } // refresh UE list based on UEs dropped by PHY in previous subframe - i = UE_list->head; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) continue; - while (i>=0) { 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"); - next_i= UE_list->next[i]; - PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63; if (i==UE_list->head) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); @@ -271,8 +269,6 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } } } // ul_failure_timer>0 - - i = next_i; } #if defined(ENABLE_ITTI) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 93dc993711..770264074f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -453,9 +453,11 @@ schedule_ue_spec( UE_sched_ctrl *ue_sched_ctl; int i; +#if 0 if (UE_list->head==-1) { return; } +#endif start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 3cf36eaa8d..db204c7762 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -107,18 +107,17 @@ DCI_PDU *get_dci_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame int find_UE_id(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { - int UE_id; UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) continue; if (UE_list->UE_template[UE_PCCID(mod_idP,UE_id)][UE_id].rnti==rntiP) { return(UE_id); } } return(-1); - } //------------------------------------------------------------------------------ @@ -235,21 +234,16 @@ void dump_ue_list(UE_list_t *listP, int ul_flag) int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) { int UE_id; - int j; + int i, j; UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; LOG_D(MAC,"[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",mod_idP,cc_idP,rntiP,UE_list->avail,UE_list->num_UEs); dump_ue_list(UE_list,0); - if (UE_list->avail>=0) { - UE_id = UE_list->avail; - AssertFatal( UE_id < NUMBER_OF_UE_MAX, "BAD UE_id %u > NUMBER_OF_UE_MAX",UE_id ); - UE_list->avail = UE_list->next[UE_list->avail]; - UE_list->next[UE_id] = UE_list->head; - UE_list->next_ul[UE_id] = UE_list->head_ul; - UE_list->head = UE_id; - UE_list->head_ul = UE_id; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] == TRUE) continue; + UE_id = i; UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; UE_list->UE_template[cc_idP][UE_id].configured = FALSE; UE_list->numactiveCCs[UE_id] = 1; @@ -282,17 +276,14 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) //------------------------------------------------------------------------------ { - - int prev,i, ret=-1; - - + int i; UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; int UE_id = find_UE_id(mod_idP,rntiP); int pCC_id; if (UE_id == -1) { LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP); - mac_phy_remove_ue(mod_idP,rntiP); + mac_phy_remove_ue(mod_idP, rntiP); return 0; } @@ -301,6 +292,9 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); dump_ue_list(UE_list,0); + UE_list->active[UE_id] = FALSE; + UE_list->num_UEs--; + // clear all remaining pending transmissions UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0; UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1] = 0; @@ -315,50 +309,6 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI; eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE; - prev = UE_list->head; - - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - if (i == UE_id) { - // link prev to next in Active list - if (i==UE_list->head) { - UE_list->head = UE_list->next[i]; - } else { - UE_list->next[prev] = UE_list->next[i]; - } - - // add UE id (i)to available - UE_list->next[i] = UE_list->avail; - UE_list->avail = i; - UE_list->active[i] = FALSE; - UE_list->num_UEs--; - ret=0; - break; - } - - prev=i; - } - - // do the same for UL - prev = UE_list->head_ul; - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - if (i == UE_id) { - // link prev to next in Active list - if (i==UE_list->head_ul) { - UE_list->head_ul = UE_list->next_ul[i]; - } else { - UE_list->next_ul[prev] = UE_list->next_ul[i]; - } - - // add UE id (i)to available - UE_list->next_ul[i] = UE_list->avail; - ret = 0; - break; - } - - prev=i; - } - mac_phy_remove_ue(mod_idP,rntiP); // check if this has an RA process active @@ -376,15 +326,8 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) //break; } } - if (ret == 0) { - return (0); - } - - LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",UE_id); - dump_ue_list(UE_list,0); - mac_xface->macphy_exit("mac_remove_ue: Problem in UE_list"); - return(-1); + return 0; } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 150f2c15de..f2f8c643e8 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -29,6 +29,9 @@ */ +#define _GNU_SOURCE +#include + #include "assertions.h" #include "PHY/defs.h" #include "PHY/extern.h" @@ -62,6 +65,17 @@ #endif */ +/* this function checks that get_eNB_UE_stats returns + * a non-NULL pointer for all CCs for a given UE + */ +static int phy_stats_exist(module_id_t Mod_id, int rnti) +{ + int CC_id; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) + if (mac_xface->get_eNB_UE_stats(Mod_id, CC_id, rnti) == NULL) + return 0; + return 1; +} // This function stores the downlink buffer for all the logical channels void store_dlsch_buffer (module_id_t Mod_id, @@ -75,7 +89,8 @@ void store_dlsch_buffer (module_id_t Mod_id, UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; UE_TEMPLATE *UE_template; - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) continue; UE_template = &UE_list->UE_template[UE_PCCID(Mod_id,UE_id)][UE_id]; @@ -153,23 +168,16 @@ void assign_rbs_required (module_id_t Mod_id, UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; // UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - int skip_ue; // clear rb allocations across all CC_ids - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) continue; + pCCid = UE_PCCID(Mod_id,UE_id); rnti = UE_list->UE_template[pCCid][UE_id].rnti; /* skip UE not present in PHY (for any of its active CCs) */ - skip_ue = 0; - for (n=0; nnumactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; - if (mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti) == NULL) { - skip_ue = 1; - break; - } - } - if (skip_ue == 1) + if (!phy_stats_exist(Mod_id, rnti)) continue; //update CQI information across component carriers @@ -302,13 +310,124 @@ int maxcqi(module_id_t Mod_id,int32_t UE_id) return(CQI); } +struct sort_ue_dl_params { + int Mod_idP; + int frameP; + int subframeP; +}; +static int ue_dl_compare(const void *_a, const void *_b, void *_params) +{ + struct sort_ue_dl_params *params = _params; + UE_list_t *UE_list = &eNB_mac_inst[params->Mod_idP].UE_list; + + int UE_id1 = *(const int *)_a; + int UE_id2 = *(const int *)_b; + + int rnti1 = UE_RNTI(params->Mod_idP, UE_id1); + int pCC_id1 = UE_PCCID(params->Mod_idP, UE_id1); + int round1 = maxround(params->Mod_idP, rnti1, params->frameP, params->subframeP, 1); + + int rnti2 = UE_RNTI(params->Mod_idP, UE_id2); + int pCC_id2 = UE_PCCID(params->Mod_idP, UE_id2); + int round2 = maxround(params->Mod_idP, rnti2, params->frameP, params->subframeP, 1); + + int cqi1 = maxcqi(params->Mod_idP, UE_id1); + int cqi2 = maxcqi(params->Mod_idP, UE_id2); + + if (round1 > round2) return -1; + if (round1 < round2) return 1; + + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return 1; + + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return 1; + + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return 1; + + if (cqi1 > cqi2) return -1; + if (cqi1 < cqi2) return 1; + + return 0; +#if 0 + /* The above order derives from the following. */ + if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order + swap_UEs(UE_list,UE_id1,UE_id2,0); + } else if (round2 == round1) { + // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. + // for(j=0;jUE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2]) < + (UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) ) { + swap_UEs(UE_list,UE_id1,UE_id2,0); + } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max ) { + swap_UEs(UE_list,UE_id1,UE_id2,0); + } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total ) { + swap_UEs(UE_list,UE_id1,UE_id2,0); + } else if (cqi1 < cqi2) { + swap_UEs(UE_list,UE_id1,UE_id2,0); + } + } +#endif +} // This fuction sorts the UE in order their dlsch buffer and CQI void sort_UEs (module_id_t Mod_idP, int frameP, sub_frame_t subframeP) { + int i; + int list[NUMBER_OF_UE_MAX]; + int list_size = 0; + int rnti; + struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP }; + + UE_list_t *UE_list = &eNB_mac_inst[Mod_idP].UE_list; + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + rnti = UE_RNTI(Mod_idP, i); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(Mod_idP, rnti)) + continue; + list[list_size] = i; + list_size++; + } + + qsort_r(list, list_size, sizeof(int), ue_dl_compare, ¶ms); + + if (list_size) { + for (i = 0; i < list_size-1; i++) + UE_list->next[list[i]] = list[i+1]; + UE_list->next[list[list_size-1]] = -1; + UE_list->head = list[0]; + } else { + UE_list->head = -1; + } + +#if 0 int UE_id1,UE_id2; @@ -329,6 +448,8 @@ void sort_UEs (module_id_t Mod_idP, continue; if (UE_list->UE_sched_ctrl[UE_id1].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(Mod_idP, rnti1)) + continue; pCC_id1 = UE_PCCID(Mod_idP,UE_id1); cqi1 = maxcqi(Mod_idP,UE_id1); // round1 = maxround(Mod_idP,rnti1,frameP,subframeP,0); @@ -339,17 +460,13 @@ void sort_UEs (module_id_t Mod_idP, continue; if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(Mod_idP, rnti2)) + continue; cqi2 = maxcqi(Mod_idP,UE_id2); round2 = maxround(Mod_idP,rnti2,frameP,subframeP,0); //mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); pCC_id2 = UE_PCCID(Mod_idP,UE_id2); - /* if 2nd UE is not in PHY, do nothing */ - if (cqi2 == -1) - continue; - /* if 1st UE is not in PHY, swap with 2nd UE */ - if (cqi1 == -1) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order + if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order swap_UEs(UE_list,UE_id1,UE_id2,0); } else if (round2 == round1) { // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. @@ -374,6 +491,7 @@ void sort_UEs (module_id_t Mod_idP, } } } +#endif } @@ -427,7 +545,9 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, min_rb_unit[CC_id]=get_min_rb_unit(Mod_id,CC_id); - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) continue; + UE_id = i; // Initialize scheduling information for all active UEs @@ -473,11 +593,9 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - UE_id = i; - - // if there is no available harq_process, skip the UE - if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) + if (!phy_stats_exist(Mod_id, rnti)) continue; + UE_id = i; for (ii=0; iiordered_CCids[ii][UE_id]; @@ -485,6 +603,10 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, harq_pid = ue_sched_ctl->harq_pid[CC_id]; round = ue_sched_ctl->round[CC_id]; + // if there is no available harq_process, skip the UE + if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) + continue; + average_rbs_per_user[CC_id]=0; frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); @@ -526,6 +648,13 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, for(i=UE_list->head; i>=0; i=UE_list->next[i]) { rnti = UE_RNTI(Mod_id,i); + if(rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(Mod_id, rnti)) + continue; + for (ii=0; iiordered_CCids[ii][i]; @@ -584,6 +713,8 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(Mod_id, rnti)) + continue; transmission_mode = mac_xface->get_transmission_mode(Mod_id,CC_id,rnti); // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); @@ -630,6 +761,8 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(Mod_idP, rnti2)) + continue; eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti2); //mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti2,frameP,subframeP,&harq_pid2,&round2,0); @@ -993,6 +1126,9 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; + UE_id = i; for (n=0; nnumactiveULCCs[UE_id]; n++) { @@ -1043,6 +1179,8 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; UE_id = i; @@ -1073,6 +1211,8 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; UE_id = i; @@ -1130,7 +1270,8 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra LTE_DL_FRAME_PARMS *frame_parms; - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) continue; rnti = UE_RNTI(module_idP,i); @@ -1138,6 +1279,8 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; if (UE_list->UE_sched_ctrl[i].phr_received == 1) mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs @@ -1221,10 +1364,103 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra } } +struct sort_ue_ul_params { + int module_idP; + int frameP; + int subframeP; +}; + +static int ue_ul_compare(const void *_a, const void *_b, void *_params) +{ + struct sort_ue_ul_params *params = _params; + UE_list_t *UE_list = &eNB_mac_inst[params->module_idP].UE_list; + + int UE_id1 = *(const int *)_a; + int UE_id2 = *(const int *)_b; + + int rnti1 = UE_RNTI(params->module_idP, UE_id1); + int pCCid1 = UE_PCCID(params->module_idP, UE_id1); + int round1 = maxround(params->module_idP, rnti1, params->frameP, params->subframeP, 1); + + int rnti2 = UE_RNTI(params->module_idP, UE_id2); + int pCCid2 = UE_PCCID(params->module_idP, UE_id2); + int round2 = maxround(params->module_idP, rnti2, params->frameP, params->subframeP, 1); + + if (round1 > round2) return -1; + if (round1 < round2) return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] > UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) + return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer > UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) + return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul > UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) + return 1; + + return 0; + +#if 0 + /* The above order derives from the following. + * The last case is not handled: "if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 )" + * I don't think it makes a big difference. + */ + if(round2 > round1) { + swap_UEs(UE_list,UE_id1,UE_id2,1); + } else if (round2 == round1) { + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) { + swap_UEs(UE_list,UE_id1,UE_id2,1); + } else if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) { + swap_UEs(UE_list,UE_id1,UE_id2,1); + } else if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) { + if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 ) { + swap_UEs(UE_list,UE_id1,UE_id2,1); + } + } + } +#endif +} void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) { + int i; + int list[NUMBER_OF_UE_MAX]; + int list_size = 0; + int rnti; + struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; + UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + rnti = UE_RNTI(module_idP, i); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; + list[list_size] = i; + list_size++; + } + + qsort_r(list, list_size, sizeof(int), ue_ul_compare, ¶ms); + + if (list_size) { + for (i = 0; i < list_size-1; i++) + UE_list->next_ul[list[i]] = list[i+1]; + UE_list->next_ul[list[list_size-1]] = -1; + UE_list->head_ul = list[0]; + } else { + UE_list->head_ul = -1; + } + +#if 0 int UE_id1,UE_id2; int pCCid1,pCCid2; int round1,round2; @@ -1246,6 +1482,8 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti1)) + continue; pCCid1 = UE_PCCID(module_idP,UE_id1); round1 = maxround(module_idP,rnti1,frameP,subframeP,1); @@ -1257,6 +1495,8 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) continue; if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(module_idP, rnti2)) + continue; pCCid2 = UE_PCCID(module_idP,UE_id2); round2 = maxround(module_idP,rnti2,frameP,subframeP,1); @@ -1276,4 +1516,5 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) } } } +#endif } From a6219153d979c5f9e449e968ad478216fec99195 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:47:08 +0100 Subject: [PATCH 92/97] check (to be reworked at some point) We put an abort() at this point in the code, because if the previous commit is correct, the program will never comme here. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index d09111290d..3fd1ba6508 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -763,6 +763,8 @@ void schedule_ulsch_rnti(module_id_t module_idP, } } if (drop_ue == 1) { +/* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ +abort(); /* TODO: this is a hack. Sometimes the UE has no PHY context but * is still present in the MAC with 'ul_failure_timer' = 0 and * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's From a0f19a726554794a87697f0114496f66e13319df Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 15:48:49 +0100 Subject: [PATCH 93/97] add some printf for debug purpose (to be remove at some point) this commit is here to help debug the previous ones. It has to be reverted at some point. --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 4 ++++ openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index e046c085e1..991f8bfbfa 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -710,7 +710,10 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un RA_template->RA_dci_size_bits2, RA_template->RA_dci_fmt2, 0); +printf("MAC: msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP); } +else +printf("MAC: msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", RA_template->rnti, round, frameP, subframeP); LOG_W(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission)\n", module_idP,CC_id,frameP,subframeP,RA_template->rnti); } else { @@ -719,6 +722,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un remove UE instance across all the layers: mac_xface->cancel_RA(); } */ +printf("MAC: msg4 acknowledged for rnti %x fsf %d/%d, let's configure it\n", RA_template->rnti, frameP, subframeP); LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",module_idP,CC_id,frameP,subframeP); RA_template->wait_ack_Msg4=0; RA_template->RA_active=FALSE; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index db204c7762..9dfd2f095b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -243,6 +243,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) for (i = 0; i < NUMBER_OF_UE_MAX; i++) { if (UE_list->active[i] == TRUE) continue; +printf("MAC: new UE id %d rnti %x\n", i, rntiP); UE_id = i; UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; UE_list->UE_template[cc_idP][UE_id].configured = FALSE; @@ -267,6 +268,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) return(UE_id); } +printf("MAC: cannot add new UE for rnti %x\n", rntiP); LOG_E(MAC,"error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); dump_ue_list(UE_list,0); return(-1); @@ -282,6 +284,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) int pCC_id; if (UE_id == -1) { +printf("MAC: cannot remove UE rnti %x\n", rntiP); LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP); mac_phy_remove_ue(mod_idP, rntiP); return 0; @@ -289,6 +292,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) pCC_id = UE_PCCID(mod_idP,UE_id); +printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP); LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); dump_ue_list(UE_list,0); From da0cbaf86c46eb4c9785125f8a599ea4ee87d882 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 16:38:26 +0100 Subject: [PATCH 94/97] fix: add /usr/include/lime to include directories when testing on haswell, using apt-get to install LimeSDR libraries and includes, it put it in /usr/include, not /usr/local/include --- cmake_targets/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 658ac84e65..94ff4b239a 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -555,6 +555,7 @@ elseif (${RF_BOARD} STREQUAL "OAI_BLADERF") elseif (${RF_BOARD} STREQUAL "OAI_LMSSDR") include_directories("${OPENAIR_TARGETS}/ARCH/LMSSDR/USERSPACE/LIB") include_directories("/usr/local/include/lime") + include_directories("/usr/include/lime") LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/lmsSDR") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/lms7002m") From 37a18b25305082549b02cef5b32e6063bcd8bc5b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 20 Jan 2017 17:22:43 +0100 Subject: [PATCH 95/97] integration fix: bad #if #endif position --- openair1/PHY/MODULATION/beamforming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 0e53f7e062..038517f692 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -115,9 +115,9 @@ int beam_precoding(int32_t **txdataF, } }*/ >>>>>>> enhancement-192-beamforming -#endif } } +#endif return 0; } From e84a00174babe2095b9e6491373befb7f1718d1c Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sat, 21 Jan 2017 16:20:10 +0100 Subject: [PATCH 96/97] choosing the right version of the unresolved merge conflict in beamforming.c changed the memory allocation of txdataF and beam_weigths --- openair1/PHY/INIT/lte_init.c | 52 ++++++++++++++------------- openair1/PHY/MODULATION/beamforming.c | 32 +---------------- targets/RT/USER/lte-enb.c | 1 - 3 files changed, 29 insertions(+), 56 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index bc74c3610e..710527ab3f 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1306,13 +1306,15 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, common_vars->txdataF_BF[eNB_id] = (int32_t **)malloc16(fp->nb_antennas_tx*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) ); + for (i=0; inb_antenna_ports_eNB || i==5) { + 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->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)); + 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++) { @@ -1328,27 +1330,29 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, #endif } - for (i=0; ibeam_weights[eNB_id][i] = (int32_t **)malloc16_clear(fp->nb_antennas_tx*sizeof(int32_t*)); - for (j=0; jnb_antennas_tx; j++) { - common_vars->beam_weights[eNB_id][i][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); - // antenna ports 0-3 are mapped on antennas 0-3 - // antenna port 4 is mapped on antenna 0 - // antenna ports 5-14 are mapped on all antennas - if (((i<4) && (i==j)) || ((i==4) && (j==0))) { - for (re=0; reofdm_symbol_size; re++) - common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff; - } - else if (i>4) { - for (re=0; reofdm_symbol_size; re++) - common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff/fp->nb_antennas_tx; - } + for (i=0; inb_antenna_ports_eNB || i==5) { + common_vars->beam_weights[eNB_id][i] = (int32_t **)malloc16_clear(fp->nb_antennas_tx*sizeof(int32_t*)); + for (j=0; jnb_antennas_tx; j++) { + common_vars->beam_weights[eNB_id][i][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); + // antenna ports 0-3 are mapped on antennas 0-3 + // antenna port 4 is mapped on antenna 0 + // antenna ports 5-14 are mapped on all antennas + if (((i<4) && (i==j)) || ((i==4) && (j==0))) { + for (re=0; reofdm_symbol_size; re++) + common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff; + } + else if (i>4) { + for (re=0; reofdm_symbol_size; re++) + common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff/fp->nb_antennas_tx; + } #ifdef DEBUG_PHY - msg("[openair][LTE_PHY][INIT] lte_common_vars->beam_weights[%d][%d][%d] = %p (%d bytes)\n", - eNB_id,i,j,common_vars->beam_weights[eNB_id][i][j], - fp->ofdm_symbol_size*sizeof(int32_t)); + msg("[openair][LTE_PHY][INIT] lte_common_vars->beam_weights[%d][%d][%d] = %p (%d bytes)\n", + eNB_id,i,j,common_vars->beam_weights[eNB_id][i][j], + fp->ofdm_symbol_size*sizeof(int32_t)); #endif - } + } + } } // RX vars diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 038517f692..88ac12b0a7 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -63,35 +63,8 @@ int beam_precoding(int32_t **txdataF, // clear txdata_BF[aa][re] for each call of ue_spec_beamforming memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size)); -#if 0 -/* TODO: to be resolved */ -<<<<<<< HEAD - 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); - 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]); - */ - } -======= for (p=0; pnb_antenna_ports_eNB || p==5) { multadd_cpx_vector((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15); //mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1); @@ -114,10 +87,7 @@ int beam_precoding(int32_t **txdataF, ((int16_t*)&txdataF_BF[aa][re])[1]); } }*/ ->>>>>>> enhancement-192-beamforming - } } -#endif return 0; } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 02a64172e3..0605dff2ab 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -2002,7 +2002,6 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->do_prach = NULL; eNB->do_precoding = 0; eNB->fep = eNB_fep_rru_if5; - eNB->do_precoding = 0; eNB->td = NULL; eNB->te = NULL; eNB->proc_uespec_rx = NULL; From 101d28e9da4df0417120a1b7f9c106e46bee7eec Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 23 Jan 2017 10:32:39 +0100 Subject: [PATCH 97/97] integration fix: fix compilation of ulsim Hopefully the right argument is passed to this function. --- openair1/SIMULATION/LTE_PHY/ulsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index cf9e5aaa30..55c6b8387e 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -1175,7 +1175,7 @@ int main(int argc, char **argv) eNB->td = (parallel_flag == 1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; eNB->do_prach = NULL; - phy_procedures_eNB_common_RX(eNB); + phy_procedures_eNB_common_RX(eNB,proc_rxtx); phy_procedures_eNB_uespec_RX(eNB,proc_rxtx,no_relay);