Conflicts: openair1/PHY/INIT/lte_init.c openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c openair1/PHY/LTE_TRANSPORT/dci.c openair1/PHY/LTE_TRANSPORT/dci_tools.c openair1/PHY/LTE_TRANSPORT/dlsch_coding.c openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c openair1/PHY/LTE_TRANSPORT/if4_tools.c openair1/PHY/LTE_TRANSPORT/if5_tools.c openair1/PHY/LTE_TRANSPORT/if5_tools.h openair1/PHY/LTE_TRANSPORT/pcfich.c openair1/PHY/LTE_TRANSPORT/phich.c openair1/PHY/LTE_TRANSPORT/prach.c openair1/PHY/LTE_TRANSPORT/rar_tools.c openair1/PHY/LTE_TRANSPORT/srs_modulation.c openair1/PHY/defs.h openair1/PHY/impl_defs_lte.h openair1/PHY/impl_defs_top.h openair1/SCHED/phy_procedures_lte_eNb.c openair1/SCHED/phy_procedures_lte_ue.c openair2/COMMON/mac_rrc_primitives.h openair2/ENB_APP/enb_config.c openair2/ENB_APP/enb_config.h openair2/LAYER2/MAC/config.c openair2/LAYER2/MAC/eNB_scheduler.c openair2/LAYER2/MAC/eNB_scheduler_dlsch.c openair2/LAYER2/MAC/eNB_scheduler_mch.c openair2/LAYER2/MAC/eNB_scheduler_primitives.c openair2/LAYER2/MAC/main.c openair2/LAYER2/MAC/proto.h openair2/RRC/LITE/MESSAGES/asn1_msg.c openair2/RRC/LITE/MESSAGES/asn1_msg.h openair2/RRC/LITE/rrc_UE.c openair2/RRC/LITE/rrc_common.c openair2/RRC/LITE/rrc_eNB.c targets/ARCH/COMMON/common_lib.c targets/ARCH/COMMON/common_lib.h targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf targets/RT/USER/lte-enb.c targets/RT/USER/lte-softmodem.c targets/RT/USER/lte-ue.c targets/RT/USER/rt_wrapper.h targets/SIMU/USER/channel_sim.c targets/SIMU/USER/init_lte.c targets/SIMU/USER/oaisim.c targets/SIMU/USER/oaisim_functions.c
172 lines
5.0 KiB
C
172 lines
5.0 KiB
C
/*
|
|
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The OpenAirInterface Software Alliance licenses this file to You under
|
|
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
|
|
* except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.openairinterface.org/?page_id=698
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*-------------------------------------------------------------------------------
|
|
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
|
* contact@openairinterface.org
|
|
*/
|
|
|
|
/*! \file common_lib.c
|
|
* \brief common APIs for different RF frontend device
|
|
* \author HongliangXU, Navid Nikaein
|
|
* \date 2015
|
|
* \version 0.2
|
|
* \company Eurecom
|
|
* \maintainer: navid.nikaein@eurecom.fr
|
|
* \note
|
|
* \warning
|
|
*/
|
|
#include <stdio.h>
|
|
#include <strings.h>
|
|
#include <dlfcn.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#include "common_lib.h"
|
|
|
|
int set_device(openair0_device *device) {
|
|
|
|
switch (device->type) {
|
|
|
|
case EXMIMO_DEV:
|
|
printf("[%s] has loaded EXPRESS MIMO device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
case USRP_B200_DEV:
|
|
printf("[%s] has loaded USRP B200 device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
case USRP_X300_DEV:
|
|
printf("[%s] has loaded USRP X300 device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
case BLADERF_DEV:
|
|
printf("[%s] has loaded BLADERF device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
case LMSSDR_DEV:
|
|
printf("[%s] has loaded LMSSDR device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
case NONE_DEV:
|
|
printf("[%s] has not loaded a HW device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
break;
|
|
default:
|
|
printf("[%s] invalid HW device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int set_transport(openair0_device *device) {
|
|
|
|
switch (device->transp_type) {
|
|
|
|
case ETHERNET_TP:
|
|
printf("[%s] has loaded ETHERNET trasport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
return 0;
|
|
break;
|
|
case NONE_TP:
|
|
printf("[%s] has not loaded a transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
return 0;
|
|
break;
|
|
default:
|
|
printf("[%s] invalid transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
|
return -1;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
/* look for the interface library and load it */
|
|
int load_lib(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * cfg, uint8_t flag) {
|
|
|
|
void *lib_handle;
|
|
oai_device_initfunc_t dp ;
|
|
oai_transport_initfunc_t tp ;
|
|
int ret=0;
|
|
|
|
if (flag == RAU_LOCAL_RADIO_HEAD) {
|
|
lib_handle = dlopen(OAI_RF_LIBNAME, RTLD_LAZY);
|
|
if (!lib_handle) {
|
|
fprintf(stderr,"Unable to locate %s: HW device set to NONE_DEV.\n", OAI_RF_LIBNAME);
|
|
fprintf(stderr,"%s\n",dlerror());
|
|
return -1;
|
|
}
|
|
|
|
dp = dlsym(lib_handle,"device_init");
|
|
|
|
if (dp != NULL ) {
|
|
ret = dp(device,openair0_cfg);
|
|
if (ret<0) {
|
|
fprintf(stderr, "%s %d:oai device intialization failed %s\n", __FILE__, __LINE__, dlerror());
|
|
}
|
|
} else {
|
|
fprintf(stderr, "%s %d:oai device intializing function not found %s\n", __FILE__, __LINE__, dlerror());
|
|
return -1;
|
|
}
|
|
} else {
|
|
lib_handle = dlopen(OAI_TP_LIBNAME, RTLD_LAZY);
|
|
if (!lib_handle) {
|
|
printf( "Unable to locate %s: transport protocol set to NONE_TP.\n", OAI_TP_LIBNAME);
|
|
printf( "%s\n",dlerror());
|
|
return -1;
|
|
}
|
|
|
|
tp = dlsym(lib_handle,"transport_init");
|
|
|
|
if (tp != NULL ) {
|
|
tp(device,openair0_cfg,cfg);
|
|
} else {
|
|
fprintf(stderr, "%s %d:oai device intializing function not found %s\n", __FILE__, __LINE__, dlerror());
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg) {
|
|
|
|
int rc=0;
|
|
rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD );
|
|
|
|
if ( rc >= 0) {
|
|
if ( set_device(device) < 0) {
|
|
fprintf(stderr, "%s %d:Unsupported radio head\n",__FILE__, __LINE__);
|
|
return -1;
|
|
}
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params) {
|
|
int rc;
|
|
rc=load_lib(device, openair0_cfg, eth_params, RAU_REMOTE_RADIO_HEAD);
|
|
if ( rc >= 0) {
|
|
if ( set_transport(device) < 0) {
|
|
fprintf(stderr, "%s %d:Unsupported transport protocol\n",__FILE__, __LINE__);
|
|
return -1;
|
|
}
|
|
}
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|