Commit c1490bb8 authored by Rohit Gupta's avatar Rohit Gupta

Merge branch 'develop' into enhancement-10-harmony

parents 1db923d6 7203a521
This diff is collapsed.
...@@ -233,7 +233,7 @@ check_install_usrp_uhd_driver(){ ...@@ -233,7 +233,7 @@ check_install_usrp_uhd_driver(){
$SUDO add-apt-repository ppa:ettusresearch/uhd -y $SUDO add-apt-repository ppa:ettusresearch/uhd -y
$SUDO apt-get update $SUDO apt-get update
$SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev
$SUDO apt-get -y install libuhd-dev libuhd003 $SUDO apt-get -y install libuhd-dev libuhd003 uhd-host
} }
install_usrp_uhd_driver() { install_usrp_uhd_driver() {
...@@ -291,7 +291,7 @@ check_install_additional_tools (){ ...@@ -291,7 +291,7 @@ check_install_additional_tools (){
$SUDO pip install paramiko $SUDO pip install paramiko
$SUDO pip install pyroute2 $SUDO pip install pyroute2
$SUDO rm -fr /opt/ssh $SUDO rm -fr /opt/ssh
$SUDO GIT_SSL_NO_VERIFY=true git clone https://gist.github.com/2190472.git /opt/ssh $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh
log_netiface=$OPENAIR_DIR/cmake_targets/log/netiface_install_log.txt log_netiface=$OPENAIR_DIR/cmake_targets/log/netiface_install_log.txt
echo_info "Installing Netinterfaces package. The logfile for installation is in $log_netiface" echo_info "Installing Netinterfaces package. The logfile for installation is in $log_netiface"
......
...@@ -59,7 +59,7 @@ PHY_VARS_UE *PHY_vars_UE; ...@@ -59,7 +59,7 @@ PHY_VARS_UE *PHY_vars_UE;
DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2_1E[2]; DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2_1E[2];
#define UL_RB_ALLOC 0x1ff; #define UL_RB_ALLOC 0x1ff;
#define CCCH_RB_ALLOC computeRIV(PHY_vars_eNB->lte_frame_parms.N_RB_UL,0,2) #define CCCH_RB_ALLOC computeRIV(PHY_vars_eNB->frame_parms.N_RB_UL,0,2)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -125,7 +125,7 @@ int main(int argc, char **argv) ...@@ -125,7 +125,7 @@ int main(int argc, char **argv)
logInit(); logInit();
number_of_cards = 1; number_of_cards = 1;
openair_daq_vars.rx_rf_mode = 1; //openair_daq_vars.rx_rf_mode = 1;
/* /*
rxdataF = (int **)malloc16(2*sizeof(int*)); rxdataF = (int **)malloc16(2*sizeof(int*));
...@@ -266,7 +266,7 @@ int main(int argc, char **argv) ...@@ -266,7 +266,7 @@ int main(int argc, char **argv)
printf("SNR0 %f, SNR1 %f\n",snr0,snr1); printf("SNR0 %f, SNR1 %f\n",snr0,snr1);
frame_parms = &PHY_vars_eNB->lte_frame_parms; frame_parms = &PHY_vars_eNB->frame_parms;
if (awgn_flag == 0) if (awgn_flag == 0)
sprintf(fname,"embms_%d_%d.m",mcs,N_RB_DL); sprintf(fname,"embms_%d_%d.m",mcs,N_RB_DL);
...@@ -292,7 +292,7 @@ int main(int argc, char **argv) ...@@ -292,7 +292,7 @@ int main(int argc, char **argv)
fflush(fd); fflush(fd);
txdata = PHY_vars_eNB->lte_eNB_common_vars.txdata[0]; txdata = PHY_vars_eNB->common_vars.txdata[0];
s_re = malloc(2*sizeof(double*)); s_re = malloc(2*sizeof(double*));
s_im = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*));
...@@ -315,49 +315,49 @@ int main(int argc, char **argv) ...@@ -315,49 +315,49 @@ int main(int argc, char **argv)
bzero(r_im[i],FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double)); bzero(r_im[i],FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double));
} }
eNB2UE = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, eNB2UE = new_channel_desc_scm(PHY_vars_eNB->frame_parms.nb_antennas_tx,
PHY_vars_UE->lte_frame_parms.nb_antennas_rx, PHY_vars_UE->frame_parms.nb_antennas_rx,
channel_model, channel_model,
N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_DL), N_RB2sampling_rate(PHY_vars_eNB->frame_parms.N_RB_DL),
N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_DL), N_RB2channel_bandwidth(PHY_vars_eNB->frame_parms.N_RB_DL),
0, 0,
0, 0,
0); 0);
// Create transport channel structures for 2 transport blocks (MIMO) // Create transport channel structures for 2 transport blocks (MIMO)
PHY_vars_eNB->dlsch_eNB_MCH = new_eNB_dlsch(1,8,Nsoft,N_RB_DL,0); PHY_vars_eNB->dlsch_MCH = new_eNB_dlsch(1,8,Nsoft,N_RB_DL,0);
if (!PHY_vars_eNB->dlsch_eNB_MCH) { if (!PHY_vars_eNB->dlsch_MCH) {
printf("Can't get eNB dlsch structures\n"); printf("Can't get eNB dlsch structures\n");
exit(-1); exit(-1);
} }
PHY_vars_UE->dlsch_ue_MCH[0] = new_ue_dlsch(1,8,Nsoft,MAX_TURBO_ITERATIONS_MBSFN,N_RB_DL,0); PHY_vars_UE->dlsch_MCH[0] = new_ue_dlsch(1,8,Nsoft,MAX_TURBO_ITERATIONS_MBSFN,N_RB_DL,0);
PHY_vars_eNB->lte_frame_parms.num_MBSFN_config = 1; PHY_vars_eNB->frame_parms.num_MBSFN_config = 1;
PHY_vars_eNB->lte_frame_parms.MBSFN_config[0].radioframeAllocationPeriod = 0; PHY_vars_eNB->frame_parms.MBSFN_config[0].radioframeAllocationPeriod = 0;
PHY_vars_eNB->lte_frame_parms.MBSFN_config[0].radioframeAllocationOffset = 0; PHY_vars_eNB->frame_parms.MBSFN_config[0].radioframeAllocationOffset = 0;
PHY_vars_eNB->lte_frame_parms.MBSFN_config[0].fourFrames_flag = 0; PHY_vars_eNB->frame_parms.MBSFN_config[0].fourFrames_flag = 0;
PHY_vars_eNB->lte_frame_parms.MBSFN_config[0].mbsfn_SubframeConfig=0xff; // activate all possible subframes PHY_vars_eNB->frame_parms.MBSFN_config[0].mbsfn_SubframeConfig=0xff; // activate all possible subframes
PHY_vars_UE->lte_frame_parms.num_MBSFN_config = 1; PHY_vars_UE->frame_parms.num_MBSFN_config = 1;
PHY_vars_UE->lte_frame_parms.MBSFN_config[0].radioframeAllocationPeriod = 0; PHY_vars_UE->frame_parms.MBSFN_config[0].radioframeAllocationPeriod = 0;
PHY_vars_UE->lte_frame_parms.MBSFN_config[0].radioframeAllocationOffset = 0; PHY_vars_UE->frame_parms.MBSFN_config[0].radioframeAllocationOffset = 0;
PHY_vars_UE->lte_frame_parms.MBSFN_config[0].fourFrames_flag = 0; PHY_vars_UE->frame_parms.MBSFN_config[0].fourFrames_flag = 0;
PHY_vars_UE->lte_frame_parms.MBSFN_config[0].mbsfn_SubframeConfig=0xff; // activate all possible subframes PHY_vars_UE->frame_parms.MBSFN_config[0].mbsfn_SubframeConfig=0xff; // activate all possible subframes
fill_eNB_dlsch_MCH(PHY_vars_eNB,mcs,1,0,0); fill_eNB_dlsch_MCH(PHY_vars_eNB,mcs,1,0,0);
fill_UE_dlsch_MCH(PHY_vars_UE,mcs,1,0,0); fill_UE_dlsch_MCH(PHY_vars_UE,mcs,1,0,0);
if (is_pmch_subframe(0,subframe,&PHY_vars_eNB->lte_frame_parms)==0) { if (is_pmch_subframe(0,subframe,&PHY_vars_eNB->frame_parms)==0) {
printf("eNB is not configured for MBSFN in subframe %d\n",subframe); printf("eNB is not configured for MBSFN in subframe %d\n",subframe);
exit(-1); exit(-1);
} else if (is_pmch_subframe(0,subframe,&PHY_vars_UE->lte_frame_parms)==0) { } else if (is_pmch_subframe(0,subframe,&PHY_vars_UE->frame_parms)==0) {
printf("UE is not configured for MBSFN in subframe %d\n",subframe); printf("UE is not configured for MBSFN in subframe %d\n",subframe);
exit(-1); exit(-1);
} }
input_buffer_length = PHY_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS/8; input_buffer_length = PHY_vars_eNB->dlsch_MCH->harq_processes[0]->TBS/8;
input_buffer = (unsigned char *)malloc(input_buffer_length+4); input_buffer = (unsigned char *)malloc(input_buffer_length+4);
memset(input_buffer,0,input_buffer_length+4); memset(input_buffer,0,input_buffer_length+4);
...@@ -392,12 +392,12 @@ int main(int argc, char **argv) ...@@ -392,12 +392,12 @@ int main(int argc, char **argv)
//if (trials%100==0) //if (trials%100==0)
//eNB2UE[0]->first_run = 1; //eNB2UE[0]->first_run = 1;
eNB2UE->first_run = 1; eNB2UE->first_run = 1;
memset(&PHY_vars_eNB->lte_eNB_common_vars.txdataF[0][0][0],0,FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t)); memset(&PHY_vars_eNB->common_vars.txdataF[0][0][0],0,FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t));
generate_mch(PHY_vars_eNB,sched_subframe,input_buffer,0); generate_mch(PHY_vars_eNB,sched_subframe,input_buffer,0);
PHY_ofdm_mod(PHY_vars_eNB->lte_eNB_common_vars.txdataF[0][0], // input, PHY_ofdm_mod(PHY_vars_eNB->common_vars.txdataF[0][0], // input,
txdata[0], // output txdata[0], // output
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*nsymb, // number of symbols LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*nsymb, // number of symbols
...@@ -405,33 +405,33 @@ int main(int argc, char **argv) ...@@ -405,33 +405,33 @@ int main(int argc, char **argv)
CYCLIC_PREFIX); CYCLIC_PREFIX);
if (n_frames==1) { if (n_frames==1) {
write_output("txsigF0.m","txsF0", &PHY_vars_eNB->lte_eNB_common_vars.txdataF[0][0][subframe*nsymb*PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size], write_output("txsigF0.m","txsF0", &PHY_vars_eNB->common_vars.txdataF[0][0][subframe*nsymb*PHY_vars_eNB->frame_parms.ofdm_symbol_size],
nsymb*PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size,1,1); nsymb*PHY_vars_eNB->frame_parms.ofdm_symbol_size,1,1);
//if (PHY_vars_eNB->lte_frame_parms.nb_antennas_tx>1) //if (PHY_vars_eNB->frame_parms.nb_antennas_tx>1)
//write_output("txsigF1.m","txsF1", &PHY_vars_eNB->lte_eNB_common_vars.txdataF[eNB_id][1][subframe*nsymb*PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size],nsymb*PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size,1,1); //write_output("txsigF1.m","txsF1", &PHY_vars_eNB->common_vars.txdataF[eNB_id][1][subframe*nsymb*PHY_vars_eNB->frame_parms.ofdm_symbol_size],nsymb*PHY_vars_eNB->frame_parms.ofdm_symbol_size,1,1);
} }
tx_lev = 0; tx_lev = 0;
for (aa=0; aa<PHY_vars_eNB->lte_frame_parms.nb_antennas_tx; aa++) { for (aa=0; aa<PHY_vars_eNB->frame_parms.nb_antennas_tx; aa++) {
tx_lev += signal_energy(&PHY_vars_eNB->lte_eNB_common_vars.txdata[eNB_id][aa] tx_lev += signal_energy(&PHY_vars_eNB->common_vars.txdata[eNB_id][aa]
[subframe*PHY_vars_eNB->lte_frame_parms.samples_per_tti], [subframe*PHY_vars_eNB->frame_parms.samples_per_tti],
PHY_vars_eNB->lte_frame_parms.samples_per_tti); PHY_vars_eNB->frame_parms.samples_per_tti);
} }
tx_lev_dB = (unsigned int) dB_fixed(tx_lev); tx_lev_dB = (unsigned int) dB_fixed(tx_lev);
if (n_frames==1) { if (n_frames==1) {
printf("tx_lev = %d (%d dB)\n",tx_lev,tx_lev_dB); printf("tx_lev = %d (%d dB)\n",tx_lev,tx_lev_dB);
// write_output("txsig0.m","txs0", &PHY_vars_eNB->lte_eNB_common_vars.txdata[0][0][subframe* PHY_vars_eNB->lte_frame_parms.samples_per_tti], // write_output("txsig0.m","txs0", &PHY_vars_eNB->common_vars.txdata[0][0][subframe* PHY_vars_eNB->frame_parms.samples_per_tti],
// PHY_vars_eNB->lte_frame_parms.samples_per_tti,1,1); // PHY_vars_eNB->frame_parms.samples_per_tti,1,1);
} }
for (i=0; i<2*frame_parms->samples_per_tti; i++) { for (i=0; i<2*frame_parms->samples_per_tti; i++) {
for (aa=0; aa<PHY_vars_eNB->lte_frame_parms.nb_antennas_tx; aa++) { for (aa=0; aa<PHY_vars_eNB->frame_parms.nb_antennas_tx; aa++) {
s_re[aa][i] = ((double)(((short *)PHY_vars_eNB->lte_eNB_common_vars.txdata[0][aa]))[(2*subframe*PHY_vars_UE->lte_frame_parms.samples_per_tti) + (i<<1)]); s_re[aa][i] = ((double)(((short *)PHY_vars_eNB->common_vars.txdata[0][aa]))[(2*subframe*PHY_vars_UE->frame_parms.samples_per_tti) + (i<<1)]);
s_im[aa][i] = ((double)(((short *)PHY_vars_eNB->lte_eNB_common_vars.txdata[0][aa]))[(2*subframe*PHY_vars_UE->lte_frame_parms.samples_per_tti) +(i<<1)+1]); s_im[aa][i] = ((double)(((short *)PHY_vars_eNB->common_vars.txdata[0][aa]))[(2*subframe*PHY_vars_UE->frame_parms.samples_per_tti) +(i<<1)+1]);
} }
} }
...@@ -440,18 +440,18 @@ int main(int argc, char **argv) ...@@ -440,18 +440,18 @@ int main(int argc, char **argv)
2*frame_parms->samples_per_tti,hold_channel); 2*frame_parms->samples_per_tti,hold_channel);
//AWGN //AWGN
sigma2_dB = 10*log10((double)tx_lev) +10*log10((double)PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size/(NB_RB*12)) - SNR; sigma2_dB = 10*log10((double)tx_lev) +10*log10((double)PHY_vars_eNB->frame_parms.ofdm_symbol_size/(NB_RB*12)) - SNR;
sigma2 = pow(10,sigma2_dB/10); sigma2 = pow(10,sigma2_dB/10);
if (n_frames==1) if (n_frames==1)
printf("Sigma2 %f (sigma2_dB %f)\n",sigma2,sigma2_dB); printf("Sigma2 %f (sigma2_dB %f)\n",sigma2,sigma2_dB);
for (i=0; i<2*frame_parms->samples_per_tti; i++) { for (i=0; i<2*frame_parms->samples_per_tti; i++) {
for (aa=0; aa<PHY_vars_eNB->lte_frame_parms.nb_antennas_rx; aa++) { for (aa=0; aa<PHY_vars_eNB->frame_parms.nb_antennas_rx; aa++) {
//printf("s_re[0][%d]=> %f , r_re[0][%d]=> %f\n",i,s_re[aa][i],i,r_re[aa][i]); //printf("s_re[0][%d]=> %f , r_re[0][%d]=> %f\n",i,s_re[aa][i],i,r_re[aa][i]);
((short*) PHY_vars_UE->lte_ue_common_vars.rxdata[aa])[(2*subframe*PHY_vars_UE->lte_frame_parms.samples_per_tti)+2*i] = ((short*) PHY_vars_UE->lte_ue_common_vars.rxdata[aa])[(2*subframe*PHY_vars_UE->frame_parms.samples_per_tti)+2*i] =
(short) (r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)); (short) (r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0));
((short*) PHY_vars_UE->lte_ue_common_vars.rxdata[aa])[(2*subframe*PHY_vars_UE->lte_frame_parms.samples_per_tti)+2*i+1] = ((short*) PHY_vars_UE->lte_ue_common_vars.rxdata[aa])[(2*subframe*PHY_vars_UE->frame_parms.samples_per_tti)+2*i+1] =
(short) (r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0)); (short) (r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0));
} }
} }
...@@ -466,7 +466,7 @@ int main(int argc, char **argv) ...@@ -466,7 +466,7 @@ int main(int argc, char **argv)
if (PHY_vars_UE->perfect_ce==1) { if (PHY_vars_UE->perfect_ce==1) {
// fill in perfect channel estimates // fill in perfect channel estimates
freq_channel(eNB2UE,PHY_vars_UE->lte_frame_parms.N_RB_DL,12*PHY_vars_UE->lte_frame_parms.N_RB_DL + 1); freq_channel(eNB2UE,PHY_vars_UE->frame_parms.N_RB_DL,12*PHY_vars_UE->frame_parms.N_RB_DL + 1);
for(k=0; k<NUMBER_OF_eNB_MAX; k++) { for(k=0; k<NUMBER_OF_eNB_MAX; k++) {
for(aa=0; aa<frame_parms->nb_antennas_tx; aa++) { for(aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
...@@ -499,30 +499,30 @@ int main(int argc, char **argv) ...@@ -499,30 +499,30 @@ int main(int argc, char **argv)
l2); l2);
} }
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->G = get_G(&PHY_vars_UE->lte_frame_parms, PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->G = get_G(&PHY_vars_UE->frame_parms,
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->nb_rb, PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->nb_rb,
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->rb_alloc_even, PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->rb_alloc_even,
get_Qm(PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->mcs), get_Qm(PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->mcs),
1,2, 1,2,
PHY_vars_UE->frame_tx,subframe); PHY_vars_UE->frame_tx,subframe);
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->Qm = get_Qm(PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->mcs); PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->Qm = get_Qm(PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->mcs);
dlsch_unscrambling(&PHY_vars_UE->lte_frame_parms,1,PHY_vars_UE->dlsch_ue_MCH[0], dlsch_unscrambling(&PHY_vars_UE->frame_parms,1,PHY_vars_UE->dlsch_MCH[0],
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->G, PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->G,
PHY_vars_UE->lte_ue_pdsch_vars_MCH[0]->llr[0],0,subframe<<1); PHY_vars_UE->lte_ue_pdsch_vars_MCH[0]->llr[0],0,subframe<<1);
ret = dlsch_decoding(PHY_vars_UE, ret = dlsch_decoding(PHY_vars_UE,
PHY_vars_UE->lte_ue_pdsch_vars_MCH[0]->llr[0], PHY_vars_UE->lte_ue_pdsch_vars_MCH[0]->llr[0],
&PHY_vars_UE->lte_frame_parms, &PHY_vars_UE->frame_parms,
PHY_vars_UE->dlsch_ue_MCH[0], PHY_vars_UE->dlsch_MCH[0],
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0], PHY_vars_UE->dlsch_MCH[0]->harq_processes[0],
subframe, subframe,
0,0,0); 0,0,0);
if (n_frames==1) if (n_frames==1)
printf("MCH decoding returns %d\n",ret); printf("MCH decoding returns %d\n",ret);
if (ret == (1+PHY_vars_UE->dlsch_ue_MCH[0]->max_turbo_iterations)) if (ret == (1+PHY_vars_UE->dlsch_MCH[0]->max_turbo_iterations))
errs[0]++; errs[0]++;
PHY_vars_UE->frame_tx++; PHY_vars_UE->frame_tx++;
...@@ -550,15 +550,15 @@ int main(int argc, char **argv) ...@@ -550,15 +550,15 @@ int main(int argc, char **argv)
if (n_frames==1) { if (n_frames==1) {
printf("Dumping PMCH files ( G %d)\n",PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->G); printf("Dumping PMCH files ( G %d)\n",PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->G);
dump_mch(PHY_vars_UE,0, dump_mch(PHY_vars_UE,0,
PHY_vars_UE->dlsch_ue_MCH[0]->harq_processes[0]->G, PHY_vars_UE->dlsch_MCH[0]->harq_processes[0]->G,
subframe); subframe);
} }
printf("Freeing dlsch structures\n"); printf("Freeing dlsch structures\n");
free_eNB_dlsch(PHY_vars_eNB->dlsch_eNB_MCH); free_eNB_dlsch(PHY_vars_eNB->dlsch_MCH);
free_ue_dlsch(PHY_vars_UE->dlsch_ue_MCH[0]); free_ue_dlsch(PHY_vars_UE->dlsch_MCH[0]);
fclose(fd); fclose(fd);
......
...@@ -621,7 +621,9 @@ typedef struct { ...@@ -621,7 +621,9 @@ typedef struct {
uint8_t DLSCH_dci_size_bits; uint8_t DLSCH_dci_size_bits;
/// DCI buffer for DLSCH /// DCI buffer for DLSCH
uint8_t DLSCH_DCI[8][(MAX_DCI_SIZE_BITS>>3)+1]; /* rounded to 32 bits unit (actual value should be 8 due to the logic
* of the function generate_dci0) */
uint8_t DLSCH_DCI[8][(((MAX_DCI_SIZE_BITS)+31)>>5)*4];
/// Number of Allocated RBs for DL after scheduling (prior to frequency allocation) /// Number of Allocated RBs for DL after scheduling (prior to frequency allocation)
uint16_t nb_rb[8]; // num_max_harq uint16_t nb_rb[8]; // num_max_harq
...@@ -645,7 +647,9 @@ typedef struct { ...@@ -645,7 +647,9 @@ typedef struct {
uint8_t assigned_mcs_ul; uint8_t assigned_mcs_ul;
/// DCI buffer for ULSCH /// DCI buffer for ULSCH
uint8_t ULSCH_DCI[8][(MAX_DCI_SIZE_BITS>>3)+1]; /* rounded to 32 bits unit (actual value should be 8 due to the logic
* of the function generate_dci0) */
uint8_t ULSCH_DCI[8][(((MAX_DCI_SIZE_BITS)+31)>>5)*4];
/// DL DAI /// DL DAI
uint8_t DAI; uint8_t DAI;
......
...@@ -577,7 +577,7 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz, ...@@ -577,7 +577,7 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
" G-PDU ltid %u size %u", " G-PDU ltid %u size %u",
tunnelEndPointKey.teid, tunnelEndPointKey.teid,
gpduLen); gpduLen);
GTPU_ERROR("Received T-PDU over non-existent tunnel end-point '%x' from "NW_IPV4_ADDR"\n", GTPU_DEBUG("Received T-PDU over non-existent tunnel end-point '%x' from "NW_IPV4_ADDR"\n",
ntohl(msgHdr->teid), NW_IPV4_ADDR_FORMAT((peerIp))); ntohl(msgHdr->teid), NW_IPV4_ADDR_FORMAT((peerIp)));
} }
......
...@@ -179,6 +179,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd ...@@ -179,6 +179,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd
int tmp; int tmp;
unsigned int user_args[4];
static unsigned int update_firmware_command; static unsigned int update_firmware_command;
static unsigned int update_firmware_address; static unsigned int update_firmware_address;
static unsigned int update_firmware_length; static unsigned int update_firmware_length;
...@@ -328,15 +330,38 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd ...@@ -328,15 +330,38 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd
acknowledge with no limit */ acknowledge with no limit */
#define MAX_IOCTL_ACK_CNT 500 #define MAX_IOCTL_ACK_CNT 500
update_firmware_command = *((unsigned int*)arg);
/* 'arg' is an unsigned long and is supposed to be big enough
* to hold an address - this hypothesis is okay for i386 and x86_64
* maybe not somewhere else
* this will probably fail with older kernels
* (works with 3.17 on x86_64)
*/
tmp = copy_from_user(&user_args, (void*)arg, 4*sizeof(unsigned int));
if (tmp) {
printk("[openair][IOCTL] UPDATE_FIRMWARE: error copying parameters to kernel-space (%d bytes uncopied).\n", tmp);
return -1;
}
update_firmware_command = user_args[0];
switch (update_firmware_command) { switch (update_firmware_command) {
case UPDATE_FIRMWARE_TRANSFER_BLOCK: case UPDATE_FIRMWARE_TRANSFER_BLOCK:
update_firmware_address = ((unsigned int*)arg)[1]; update_firmware_address = user_args[1];
update_firmware_length = ((unsigned int*)arg)[2]; update_firmware_length = user_args[2];
/* This is totally wrong on x86_64: a pointer is 64 bits and
* unsigned int is 32 bits. The userspace program has to ensure
* that its buffer address fits into 32 bits.
* If it proves a too strong requirement, we may change things
* in the future.
* The compiler emits a warning here. Do not remove this warning!
* This is to clearly remember this problem.
* If you require the compilation to work with zero warning,
* consider this one as an exception and find a proper workaround.
*/
update_firmware_ubuffer = user_args[3];
update_firmware_ubuffer = (unsigned int*)((unsigned int*)arg)[3];
update_firmware_kbuffer = (unsigned int*)kmalloc(update_firmware_length * 4 /* 4 because kmalloc expects bytes */, update_firmware_kbuffer = (unsigned int*)kmalloc(update_firmware_length * 4 /* 4 because kmalloc expects bytes */,
GFP_KERNEL); GFP_KERNEL);
...@@ -390,8 +415,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd ...@@ -390,8 +415,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd
case UPDATE_FIRMWARE_CLEAR_BSS: case UPDATE_FIRMWARE_CLEAR_BSS:
update_firmware_bss_address = ((unsigned int*)arg)[1]; update_firmware_bss_address = user_args[1];
update_firmware_bss_size = ((unsigned int*)arg)[2]; update_firmware_bss_size = user_args[2];
sparc_tmp_0 = update_firmware_bss_address; sparc_tmp_0 = update_firmware_bss_address;
sparc_tmp_1 = update_firmware_bss_size; sparc_tmp_1 = update_firmware_bss_size;
...@@ -411,8 +436,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd ...@@ -411,8 +436,8 @@ int openair_device_ioctl(struct inode *inode,struct file *filp, unsigned int cmd
case UPDATE_FIRMWARE_START_EXECUTION: case UPDATE_FIRMWARE_START_EXECUTION:
update_firmware_start_address = ((unsigned int*)arg)[1]; update_firmware_start_address = user_args[1];
update_firmware_stack_pointer = ((unsigned int*)arg)[2]; update_firmware_stack_pointer = user_args[2];
sparc_tmp_0 = update_firmware_start_address; sparc_tmp_0 = update_firmware_start_address;
sparc_tmp_1 = update_firmware_stack_pointer; sparc_tmp_1 = update_firmware_stack_pointer;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <getopt.h> #include <getopt.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "openair_device.h" #include "openair_device.h"
...@@ -239,6 +240,18 @@ void find_and_transfer_section(char* section_name, unsigned int verboselevel) { ...@@ -239,6 +240,18 @@ void find_and_transfer_section(char* section_name, unsigned int verboselevel) {
/* Dynamically allocate a chunk of memory to store the section into. */ /* Dynamically allocate a chunk of memory to store the section into. */
section_content = (char*)malloc(elf_Shdr.sh_size); section_content = (char*)malloc(elf_Shdr.sh_size);
/* Fail if the address returned by malloc does not fit in 32 bits.
* The kernel driver gets this address as 32 bits and uses it to copy
* from userspace. If the address does not fit into 32 bits the kernel
* will copy garbage or fail to copy completely.
* To be reworked if things do not work on some setups.
*/
if (sizeof(char*) > 4 && (((uintptr_t)section_content)>>32)) {
fprintf(stderr, "FATAL ERROR: an internal serious problem has been encountered.\n");
fprintf(stderr, "Contact the authors so as to solve this issue.\n");
exit(-1);
}
if (!section_content) { if (!section_content) {
fprintf(stderr, "Error: could not dynamically allocate %d bytes for section %s.\n", fprintf(stderr, "Error: could not dynamically allocate %d bytes for section %s.\n",
elf_Shdr.sh_size, SecNameStnTable + elf_Shdr.sh_name); elf_Shdr.sh_size, SecNameStnTable + elf_Shdr.sh_name);
...@@ -281,6 +294,13 @@ void find_and_transfer_section(char* section_name, unsigned int verboselevel) { ...@@ -281,6 +294,13 @@ void find_and_transfer_section(char* section_name, unsigned int verboselevel) {
ioctl_params[0] = UPDATE_FIRMWARE_TRANSFER_BLOCK; ioctl_params[0] = UPDATE_FIRMWARE_TRANSFER_BLOCK;
ioctl_params[1] = elf_Shdr.sh_addr; ioctl_params[1] = elf_Shdr.sh_addr;
ioctl_params[2] = elf_Shdr.sh_size / 4; ioctl_params[2] = elf_Shdr.sh_size / 4;
/* This is wrong on x86_64 because a pointer is 64 bits and
* an unsigned int is only 32 bits.
* The compiler emits a warning, but the test
* above on the value of section_content makes it work
* (hopefully).
* To be changed if things do not work.
*/
ioctl_params[3] = (unsigned int)((unsigned int*)section_content); ioctl_params[3] = (unsigned int)((unsigned int*)section_content);
//invert4(ioctl_params[1]); //invert4(ioctl_params[1]);
//invert4(ioctl_params[2]); //invert4(ioctl_params[2]);
......
...@@ -50,7 +50,7 @@ eNBs = ...@@ -50,7 +50,7 @@ eNBs =
pucch_nRB_CQI = 1; pucch_nRB_CQI = 1;