Commit 20fd3906 authored by Rajeev Gangula's avatar Rajeev Gangula

UAV BS TDD old version.

parent 1fcf4479
......@@ -111,6 +111,20 @@ ID = ENB_MAC_UE_DL_PDU_WITH_DATA
DESC = MAC downlink PDU for an UE
GROUP = ALL:MAC:ENB
FORMAT = int,eNB_ID : int,CC_id : int,rnti : int,frame : int,subframe : int,harq_pid : buffer,data
ID = ENB_TPC_DLSCH
DESC = MAC TPC PUCCH command
GROUP = ALL:MAC:ENB
FORMAT = int,frame : int,subframe : int,rnti : int,tpc : int,tpc_accumulated : int,normalized_rx_power : int,target_rx_power
ID = ENB_TPC_ULSCH
DESC = MAC TPC PUSCH command
GROUP = ALL:MAC:ENB
FORMAT = int,frame : int,subframe : int,rnti : int,tpc : int,tpc_accumulated : int,normalized_rx_power : int,target_rx_power
ID = ENB_TPC_ULSCH_PHR
DESC = MAC PHR Report
GROUP = ALL:MAC:ENB
FORMAT = int,UE_id : int,PHR
#RLC logs
ID = ENB_RLC_DL
......@@ -254,6 +268,11 @@ ID = ENB_RRC_UNKNOW_MESSAGE
GROUP = ALL:RRC:ENB
FORMAT = int,eNB_ID : int,frame : int,subframe : int,rnti
ID = ENB_RRC_RSRP
DESC = RSRP Measurements
GROUP = ALL:RRC:ENB
FORMAT = int,rnti : int,RSRP
#legacy logs
ID = LEGACY_MAC_INFO
DESC = MAC legacy logs - info level
......
......@@ -120,7 +120,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements[eNB_id];
LTE_eNB_SRS *srs_vars = &eNB->srs_vars[UE_id];
int32_t aarx,rx_power_correction;
int32_t aarx,rx_power_correction=1;
int32_t rx_power;
uint32_t rb;
int32_t *ul_ch;
......@@ -132,13 +132,13 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
rx_power = 0;
/*
if ( (frame_parms->ofdm_symbol_size == 128) ||
(frame_parms->ofdm_symbol_size == 512) )
rx_power_correction = 2;
else
rx_power_correction = 1;
*/
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
......@@ -157,7 +157,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
measurements->wideband_cqi[UE_id][aarx] = measurements->rx_spatial_power[UE_id][0][aarx];
//LOG_I(PHY,"lte_eNB_srs_measurements: UE %d, ant %d, CQI %d dB\n",UE_id,aarx,measurements->wideband_cqi[UE_id][aarx]);
// measurements->rx_power[UE_id][aarx]/=frame_parms->nb_antennas_tx;
measurements->wideband_cqi_dB[UE_id][aarx] = (unsigned short) dB_fixed(measurements->wideband_cqi[UE_id][aarx]);
......
......@@ -2149,6 +2149,7 @@ uint8_t generate_dci_top(uint8_t num_ue_spec_dci,
dci_alloc[i].dci_pdu);
dump_dci(frame_parms,&dci_alloc[i]);
#endif
dump_dci(frame_parms,&dci_alloc[i]);
if (dci_alloc[i].firstCCE >= 0) {
e_ptr = generate_dci0(dci_alloc[i].dci_pdu,
......
......@@ -2852,6 +2852,17 @@ int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci)
break;
case 25:
/*printf("DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n",
dci->rnti,
((uint32_t*)&dci->dci_pdu[0])[0],
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai,
((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req);*/
LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n",
dci->rnti,
((uint32_t*)&dci->dci_pdu[0])[0],
......
......@@ -914,8 +914,9 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
G = nb_rb * (12 * Q_m) * ulsch_harq->Nsymb_pusch;
#ifdef DEBUG_ULSCH_DECODING
printf("ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d, subframe %d\n",
//#ifdef DEBUG_ULSCH_DECODING
if(ulsch_harq->mcs > 4)
printf("ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d, %d.%d harq %d Or1 %d nb_rb %d\n",
frame_parms->Nid_cell,ulsch->rnti,x2,
ulsch_harq->round,
ulsch_harq->rvidx,
......@@ -923,8 +924,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
ulsch_harq->O_RI,
ulsch_harq->O_ACK,
G,
subframe);
#endif
proc->frame_rx, subframe, harq_pid, ulsch_harq->Or1, nb_rb);
//#endif
if (ulsch_harq->round == 0) {
// This is a new packet, so compute quantities regarding segmentation
......
......@@ -297,7 +297,7 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
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; l<frame_parms->symbols_per_tti>>1; l++) {
if (PHY_vars_eNB_g[0][0]->proc.frame_tx==0) LOG_I(PHY,"Generating symbol %d for slot %d\n",l,next_slot);
//if (PHY_vars_eNB_g[0][0]->proc.frame_tx==0) LOG_I(PHY,"Generating symbol %d for slot %d\n",l,next_slot);
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
//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);
......
......@@ -188,11 +188,15 @@ typedef struct {
} PHY_VARS_RN;
/// Context data structure for RX/TX portion of subframe processing
typedef struct {
typedef struct eNB_rxtx_proc_t_s{
/// Component Carrier index
uint8_t CC_id;
/// timestamp transmitted to HW
openair0_timestamp timestamp_tx;
//Now timestamp_rx is stored in proc, before it was a common variable in eNB struct
openair0_timestamp timestamp_rx;
//Now offset is stored in proc, before it was a common variable in eNB struct
openair0_timestamp ts_offset;
/// subframe to act upon for transmission
int subframe_tx;
/// subframe to act upon for reception
......@@ -216,6 +220,11 @@ typedef struct {
struct sched_param sched_param_rxtx;
} eNB_rxtx_proc_t;
typedef struct {
struct eNB_proc_t_s *argeNBProc;
struct eNB_rxtx_proc_t_s *argeNBproc_rxtx;
} enB_thread_params;
typedef struct {
struct PHY_VARS_eNB_s *eNB;
int UE_id;
......@@ -240,6 +249,8 @@ typedef struct eNB_proc_t_s {
openair0_timestamp timestamp_rx;
/// timestamp to send to "slave rru"
openair0_timestamp timestamp_tx;
//Now offset is stored in proc, before it was a common variable in eNB struct
openair0_timestamp ts_offset;
/// subframe to act upon for reception
int subframe_rx;
/// subframe to act upon for transmission
......@@ -278,6 +289,9 @@ typedef struct eNB_proc_t_s {
pthread_t pthread_FH;
/// pthread structure for eNB single processing thread
pthread_t pthread_single;
/// pthread structure for eNB two threads
pthread_t pthread_odd;
pthread_t pthread_even;
/// pthread structure for asychronous RX/TX processing thread
pthread_t pthread_asynch_rxtx;
/// flag to indicate first RX acquisition
......@@ -342,6 +356,10 @@ typedef struct eNB_proc_t_s {
pthread_cond_t cond_asynch_rxtx;
/// mutex for parallel fep thread
pthread_mutex_t mutex_fep;
/// Mutex locks for rf read, enb RX func, Tx process+write
pthread_mutex_t mutex_rxRf;
pthread_mutex_t mutex_rxnew;
pthread_mutex_t mutex_txnew;
/// mutex for parallel turbo-decoder thread
pthread_mutex_t mutex_td;
/// mutex for parallel turbo-encoder thread
......@@ -436,6 +454,7 @@ typedef struct PHY_VARS_eNB_s {
module_id_t Mod_id;
uint8_t CC_id;
eNB_proc_t proc;
eNB_proc_t proc_new[2];
eNB_func_t node_function;
eNB_timing_t node_timing;
eth_params_t *eth_params;
......
......@@ -102,7 +102,8 @@ double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012
};
//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
//int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 25, 25};
//for SNR to MI conversion 7 th order Polynomial coeff
double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
......
......@@ -497,7 +497,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
// generate Cell-Specific Reference Signals for both slots
if (eNB->abstraction_flag==0) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1);
if (frame==0) LOG_I(PHY,"Generating RS for slot %d\n",subframe<<1);
//if (frame==0) LOG_I(PHY,"Generating RS for slot %d\n",subframe<<1);
generate_pilots_slot(eNB,
txdataF,
AMP,
......@@ -599,7 +599,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
if ((fp->frame_type == TDD)&&
(eNB->abstraction_flag==0)){
if (frame==0) LOG_I(PHY,"Generating SSS for slot %d\n",1+(subframe<<1));
//if (frame==0) LOG_I(PHY,"Generating SSS for slot %d\n",1+(subframe<<1));
generate_sss(txdataF,
AMP,
fp,
......@@ -626,7 +626,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
else if ((subframe == 1) &&
(fp->frame_type == TDD)&&
(eNB->abstraction_flag==0)) {
if (frame==0) LOG_I(PHY,"Generating PSS for slot %d\n",subframe<<1);
//if (frame==0) LOG_I(PHY,"Generating PSS for slot %d\n",subframe<<1);
generate_pss(txdataF,
AMP,
fp,
......@@ -1360,9 +1360,9 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
if (UE_id<0) { // should not happen, log an error and exit, this is a fatal error
LOG_E(PHY,"[eNB %"PRIu8"] Frame %d: Unknown UE_id for rnti %"PRIx16"\n",eNB->Mod_id,frame,dci_alloc->rnti);
mac_xface->macphy_exit("FATAL\n");
//mac_xface->macphy_exit("FATAL\n");
}
generate_eNB_ulsch_params(eNB,proc,dci_alloc,UE_id);
if (UE_id >= 0) generate_eNB_ulsch_params(eNB,proc,dci_alloc,UE_id);
}
}
......@@ -1386,7 +1386,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (common %"PRIu8",ue_spec %"PRIu8")\n",eNB->Mod_id,frame, subframe,
DCI_pdu->Num_common_dci,DCI_pdu->Num_ue_spec_dci);
}
if (frame==0) LOG_I(PHY,"Generating PDCCCH/PCFICH for slot %d\n",subframe<<1);
// if (frame==0) LOG_I(PHY,"Generating PDCCCH/PCFICH for slot %d\n",subframe<<1);
num_pdcch_symbols = generate_dci_top(DCI_pdu->Num_ue_spec_dci,
DCI_pdu->Num_common_dci,
DCI_pdu->dci_alloc,
......@@ -2869,6 +2869,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){
}
static char subframe_null[7680*4*4];
void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type)
{
//RX processing for ue-specific resources (i
......@@ -2892,6 +2893,13 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
T(T_ENB_PHY_UL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe));
/* if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) {
T(T_ENB_PHY_INPUT_SIGNAL, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(0),
T_BUFFER(subframe_null,
eNB->frame_parms.samples_per_tti * 4));
return;
}*/
T(T_ENB_PHY_INPUT_SIGNAL, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(0),
T_BUFFER(&eNB->common_vars.rxdata[0][0][subframe*eNB->frame_parms.samples_per_tti],
eNB->frame_parms.samples_per_tti * 4));
......@@ -2943,6 +2951,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
0/*eNB_id*/)) {
LOG_E(PHY,"problem processing SRS\n");
}
lte_eNB_srs_measurements(eNB,0/*eNB_id*/,i,0/*init_averaging*/);
}
// Do PUCCH processing
......@@ -3083,6 +3093,19 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0],
eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1],
ret);
/*printf("[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n",
eNB->Mod_id,harq_pid,
frame,subframe,
eNB->ulsch[i]->rnti,
dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]),
dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
eNB->UE_stats[i].UL_rssi[0],
eNB->UE_stats[i].UL_rssi[1],
eNB->measurements->n0_power_dB[0],
eNB->measurements->n0_power_dB[1],
eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0],
eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1],
ret);*/
//compute the expected ULSCH RX power (for the stats)
eNB->ulsch[(uint32_t)i]->harq_processes[harq_pid]->delta_TF =
......
......@@ -1196,6 +1196,8 @@ schedule_ue_spec(
} else {
tpc = 1; //0
}
//if (tpc != 1)
T(T_ENB_TPC_DLSCH, T_INT(frameP), T_INT(subframeP), T_INT(rnti), T_INT(tpc), T_INT(tpc_accumulated), T_INT(normalized_rx_power), T_INT(target_rx_power));
/*
LOG_I(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
module_idP,frameP, subframeP,harq_pid,tpc,
......
......@@ -317,6 +317,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP)
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);
printf("in rrc_mac_remove_ue %d\n", UE_id);
return 0;
}
......
......@@ -139,6 +139,10 @@ void rx_sdu(const module_id_t enb_mod_idP,
UE_list->UE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET;
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n",
enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info);
T(T_ENB_TPC_ULSCH_PHR, T_INT(UE_id), T_INT(UE_list->UE_template[CC_idP][UE_id].phr_info));
UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1;
UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
}
......@@ -726,6 +730,8 @@ void schedule_ulsch_rnti(module_id_t module_idP,
// LOG_I(MAC,"entering ulsch preprocesor\n");
//if (subframeP == 0) return;
ulsch_scheduler_pre_processor(module_idP,
frameP,
subframeP,
......@@ -871,6 +877,10 @@ abort();
module_idP,frameP,subframeP,harq_pid,tpc,
tpc_accumulated,normalized_rx_power,target_rx_power);
}
//if (tpc != 1)
T(T_ENB_TPC_ULSCH, T_INT(frameP), T_INT(subframeP), T_INT(rnti), T_INT(tpc), T_INT(tpc_accumulated), T_INT(normalized_rx_power), T_INT(target_rx_power));
// new transmission
if (round==0) {
......@@ -884,7 +894,7 @@ abort();
if (UE_template->pre_allocated_rb_table_index_ul >=0) {
rb_table_index=UE_template->pre_allocated_rb_table_index_ul;
} else {
mcs=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs);
mcs=4;//cmin (10, openair_daq_vars.target_ue_ul_mcs);
rb_table_index=5; // for PHR
}
......
......@@ -1304,9 +1304,9 @@ 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].phr_received == 1)
mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs
mcs = 20; //20 before // if we've received the power headroom information the UE, we can go to maximum mcs
else
mcs = 10; // otherwise, limit to QPSK PUSCH
mcs = 10; //10 before // otherwise, limit to QPSK PUSCH
UE_id = i;
......@@ -1339,7 +1339,7 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra
// fixme: set use_srs flag
tx_power= mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0);
while ((((UE_template->phr_info - tx_power) < 0 ) || (tbs > UE_template->ul_total_buffer))&&
while ((((UE_template->phr_info - tx_power) < -5 ) || (tbs > UE_template->ul_total_buffer))&&
(mcs > 3)) {
// LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs);
mcs--;
......@@ -1377,6 +1377,12 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra
UE_template->pre_allocated_rb_table_index_ul,
UE_template->pre_allocated_nb_rb_ul,
UE_template->phr_info,tx_power);
printf("[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n",
module_idP, frameP, subframeP, UE_id, CC_id,
UE_template->pre_assigned_mcs_ul,
UE_template->pre_allocated_rb_table_index_ul,
UE_template->pre_allocated_nb_rb_ul,
UE_template->phr_info,tx_power);
} else {
UE_template->pre_allocated_rb_table_index_ul=-1;
UE_template->pre_allocated_nb_rb_ul=0;
......
This diff is collapsed.
......@@ -42,6 +42,8 @@
#include "common_lib.h"
#include "assertions.h"
#include <uhd/types/tune_request.hpp>
#ifdef __SSE4_1__
# include <smmintrin.h>
#endif
......@@ -78,6 +80,9 @@ typedef struct {
//! USRP RX Metadata
uhd::rx_metadata_t rx_md;
uhd::tune_request_t tu_req;
//! Sampling rate
double sample_rate;
......@@ -106,6 +111,19 @@ static int trx_usrp_start(openair0_device *device) {
usrp_state_t *s = (usrp_state_t*)device->priv;
//uint8_t mask=0x0f;
// uint8_t ddr=0x07;
// uint8_t ctrlm=0x07;
// uint8_t atr_r=0x03;
// uint8_t atr_t=0x04;
//
// s->usrp->set_gpio_attr("FP0", "DDR", ddr, 0x1f);
// s->usrp->set_gpio_attr("FP0", "CTRL", ctrlm,0x1f);
// s->usrp->set_gpio_attr("FP0", "ATR_RX", atr_r, 0x1f);
// s->usrp->set_gpio_attr("FP0", "ATR_XX", atr_t, 0x1f);
// setup GPIO for TDD, GPIO(4) = ATR_RX
//set data direction register (DDR) to output
......@@ -115,7 +133,11 @@ static int trx_usrp_start(openair0_device *device) {
s->usrp->set_gpio_attr("FP0", "CTRL", 0x1f,0x1f);
//set ATR register
s->usrp->set_gpio_attr("FP0", "ATR_RX", 1<<4, 0x1f);
s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4), 0x1f);
// init recv and send streaming
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
......@@ -156,7 +178,20 @@ static void trx_usrp_end(openair0_device *device) {
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
*/
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
int ret=0;
int ret=0,nsamps2;
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
#else
nsamps2 = (nsamps+3)>>2;
#endif
#elif defined(__arm__)
nsamps2 = (nsamps+3)>>2;
#endif
uint32_t tx_buff[nsamps] __attribute__ ((aligned(32)));
usrp_state_t *s = (usrp_state_t*)device->priv;
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
......@@ -182,13 +217,28 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
s->tx_md.end_of_burst = false;
}
// bring RX data into 12 MSBs for USRP::Shift by 4 bits to left
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
((__m256i *)tx_buff)[j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#else
((__m128i *)tx_buff)[j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4);
#endif
#elif defined(__arm__)
((int16x8_t*)tx_buff)[j] = vshrq_n_s16(buff[i][j],4);
#endif
}
}
if (cc>1) {
std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(buff[i]);
buff_ptrs.push_back(tx_buff);
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(buff[0], nsamps, s->tx_md,1e-3);
ret = (int)s->tx_stream->send(tx_buff, nsamps, s->tx_md,1e-3);
......@@ -292,9 +342,17 @@ void *freq_thread(void *arg) {
openair0_device *device=(openair0_device *)arg;
usrp_state_t *s = (usrp_state_t*)device->priv;
printf("Setting USRP TX Freq %f, RX Freq %f\n",device->openair0_cfg[0].tx_freq[0],device->openair0_cfg[0].rx_freq[0]);
s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]);
s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]);
// change to advanced lo offset from above line
//uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0],(double)20000000);
//rx_tune_req.rf_freq_policy=uhd::tune_request_t::POLICY_MANUAL;
//rx_tune_req.rf_freq=device->openair0_cfg[0].rx_freq[0]-(double)20000000;
//s->usrp->set_rx_freq(rx_tune_req);
//printf("Actual USRP RX Freq %f\n",s->usrp->get_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
......@@ -315,6 +373,12 @@ int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg,
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]);
// change to advanced lo offset from above line
//uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0],(double)20000000);
//rx_tune_req.rf_freq_policy=uhd::tune_request_t::POLICY_MANUAL;
//rx_tune_req.rf_freq=device->openair0_cfg[0].rx_freq[0]-(double)20000000;
//s->usrp->set_rx_freq(rx_tune_req);
//printf("Actual USRP RX Freq %f\n",s->usrp->get_rx_freq(0));
}
return(0);
......@@ -331,14 +395,15 @@ int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *open
usrp_state_t *s = (usrp_state_t*)device->priv;
static int first_call=1;
static double rf_freq,diff;
printf("Setting USRP TX RX Freq %f\n",openair0_cfg[0].rx_freq[0]);
uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0]);
uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0],(double)20000000);
rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0];
rf_freq=openair0_cfg[0].rx_freq[0];
//rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0];
//rf_freq=openair0_cfg[0].rx_freq[0];
s->usrp->set_rx_freq(rx_tune_req);
printf("Actual USRP RX Freq %f\n",s->usrp->get_rx_freq(0));
return(0);
}
......@@ -638,7 +703,16 @@ extern "C" {
for(int i=0; i<s->usrp->get_rx_num_channels(); i++) {
if (i<openair0_cfg[0].rx_num_channels) {
s->usrp->set_rx_rate(openair0_cfg[0].sample_rate,i);
s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i);
// uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0],(double)12000000);
//rx_tune_req.rf_freq_policy=uhd::tune_request_t::POLICY_MANUAL;
//rx_tune_req.rf_freq=device->openair0_cfg[0].rx_freq[0]-(double)20000000;
//s->usrp->set_rx_freq(rx_tune_req);
//printf("\n*****\n Desired USRP RX Freq %f\n",openair0_cfg[0].rx_freq[0]);
//printf("\n*****\n Actual USRP RX Freq %f\n",s->usrp->get_rx_freq(0));
set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust);
::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i);
......
This diff is collapsed.
......@@ -1344,7 +1344,7 @@ void init_openair0() {
openair0_cfg[card].autocal[i] = 1;
openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
if (UE_flag == 0) {
openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB;
openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB- rx_gain_off;
}
else {
openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off;
......@@ -1661,7 +1661,7 @@ int main( int argc, char **argv ) {
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];
PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]+ rx_gain_off;
if (frame_parms[CC_id]->frame_type==FDD) {
PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment